2017-05-03 15:35:00 +02:00
# os-locale [![Build Status](https://travis-ci.org/sindresorhus/os-locale.svg?branch=master)](https://travis-ci.org/sindresorhus/os-locale)
2017-08-14 05:01:11 +02:00
> Get the system [locale](https://en.wikipedia.org/wiki/Locale_(computer_software))
2017-05-03 15:35:00 +02:00
Useful for localizing your module or app.
POSIX 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.
## Install
```
$ npm install --save os-locale
```
## Usage
```js
2017-08-14 05:01:11 +02:00
const osLocale = require('os-locale');
2017-05-03 15:35:00 +02:00
2017-08-14 05:01:11 +02:00
osLocale().then(locale => {
2017-05-03 15:35:00 +02:00
console.log(locale);
//=> 'en_US'
});
```
## API
2017-08-14 05:01:11 +02:00
### osLocale([options])
Returns a `Promise` for the locale.
2017-05-03 15:35:00 +02:00
### osLocale.sync([options])
Returns the locale.
2017-08-14 05:01:11 +02:00
#### options
Type: `Object`
##### spawn
2017-05-03 15:35:00 +02:00
2017-08-14 05:01:11 +02:00
Type: `boolean` < br >
2017-05-03 15:35:00 +02:00
Default: `true`
Set to `false` to avoid spawning subprocesses and instead only resolve the locale from environment variables.
## License
2017-08-14 05:01:11 +02:00
MIT © [Sindre Sorhus ](https://sindresorhus.com )