UNPKG

1.39 kBMarkdownView Raw
1# os-locale
2
3> Get the system [locale](https://en.wikipedia.org/wiki/Locale_(computer_software))
4
5Useful for localizing your module or app.
6
7POSIX systems: The returned locale refers to the [`LC_MESSAGE`](http://www.gnu.org/software/libc/manual/html_node/Locale-Categories.html#Locale-Categories) category, suitable for selecting the language used in the user interface for message translation.
8
9## Install
10
11```
12$ npm install os-locale
13```
14
15## Usage
16
17```js
18import {osLocale} from 'os-locale';
19
20console.log(await osLocale());
21//=> 'en-US'
22```
23## API
24
25### osLocale(options?)
26
27Returns a `Promise` for the locale.
28
29### osLocaleSync(options?)
30
31Returns the locale.
32
33#### options
34
35Type: `object`
36
37##### spawn
38
39Type: `boolean`\
40Default: `true`
41
42Set to `false` to avoid spawning subprocesses and instead only resolve the locale from environment variables.
43
44## os-locale for enterprise
45
46Available as part of the Tidelift Subscription.
47
48The maintainers of os-locale and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-os-locale?utm_source=npm-os-locale&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)