Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/os-locale
Get the system locale
https://github.com/sindresorhus/os-locale
Last synced: about 16 hours ago
JSON representation
Get the system locale
- Host: GitHub
- URL: https://github.com/sindresorhus/os-locale
- Owner: sindresorhus
- License: mit
- Created: 2015-03-16T07:09:09.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2021-12-23T14:01:07.000Z (about 3 years ago)
- Last Synced: 2024-10-29T12:58:43.464Z (3 months ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 225
- Watchers: 12
- Forks: 44
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-nodejs-cn - os-locale - 获取系统 locale (包 / 其他)
- awesome-nodejs-cn - os-locale - **star:225** 获取系统区域设置 (包 / 杂项)
- awesome-nodejs - os-locale - Get the system locale. (Packages / Miscellaneous)
- awesome-nodejs - os-locale - Get the system locale - ★ 134 (Miscellaneous)
- awesome-node - os-locale - Get the system locale. (Packages / Miscellaneous)
README
# os-locale
> Get the system [locale](https://en.wikipedia.org/wiki/Locale_(computer_software))
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 os-locale
```## Usage
```js
import {osLocale} from 'os-locale';console.log(await osLocale());
//=> 'en-US'
```
## API### osLocale(options?)
Returns a `Promise` for the locale.
### osLocaleSync(options?)
Returns the locale.
#### options
Type: `object`
##### spawn
Type: `boolean`\
Default: `true`Set to `false` to avoid spawning subprocesses and instead only resolve the locale from environment variables.
## os-locale for enterprise
Available as part of the Tidelift Subscription.
The 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)