-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocale.ts
More file actions
57 lines (53 loc) · 1.36 KB
/
locale.ts
File metadata and controls
57 lines (53 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* @file Locale and language environment variable getters. Provides access to
* system locale settings.
*/
import { getEnvValue } from './rewire'
/**
* LANG environment variable. System locale and language settings.
*
* @example
* ;```typescript
* import { getLang } from '@socketsecurity/lib/env/locale'
*
* const lang = getLang()
* // e.g. 'en_US.UTF-8' or undefined
* ```
*
* @returns The system locale string, or `undefined` if not set
*/
export function getLang(): string | undefined {
return getEnvValue('LANG')
}
/**
* LC_ALL environment variable. Override for all locale settings.
*
* @example
* ;```typescript
* import { getLcAll } from '@socketsecurity/lib/env/locale'
*
* const lcAll = getLcAll()
* // e.g. 'C' or 'en_US.UTF-8'
* ```
*
* @returns The locale override string, or `undefined` if not set
*/
export function getLcAll(): string | undefined {
return getEnvValue('LC_ALL')
}
/**
* LC_MESSAGES environment variable. Locale setting for message translations.
*
* @example
* ;```typescript
* import { getLcMessages } from '@socketsecurity/lib/env/locale'
*
* const lcMessages = getLcMessages()
* // e.g. 'en_US.UTF-8' or undefined
* ```
*
* @returns The messages locale string, or `undefined` if not set
*/
export function getLcMessages(): string | undefined {
return getEnvValue('LC_MESSAGES')
}