You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.6 KiB

4 years ago
  1. # os-locale [![Build Status](https://travis-ci.org/sindresorhus/os-locale.svg?branch=master)](https://travis-ci.org/sindresorhus/os-locale)
  2. > Get the system [locale](https://en.wikipedia.org/wiki/Locale_(computer_software))
  3. Useful for localizing your module or app.
  4. 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.
  5. ---
  6. <div align="center">
  7. <b>
  8. <a href="https://tidelift.com/subscription/pkg/npm-os-locale?utm_source=npm-os-locale&utm_medium=referral&utm_campaign=readme">Get professional support for 'os-locale' with a Tidelift subscription</a>
  9. </b>
  10. <br>
  11. <sub>
  12. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  13. </sub>
  14. </div>
  15. ---
  16. ## Install
  17. ```
  18. $ npm install os-locale
  19. ```
  20. ## Usage
  21. ```js
  22. const osLocale = require('os-locale');
  23. (async () => {
  24. console.log(await osLocale());
  25. //=> 'en_US'
  26. })();
  27. ```
  28. ## API
  29. ### osLocale([options])
  30. Returns a `Promise` for the locale.
  31. ### osLocale.sync([options])
  32. Returns the locale.
  33. #### options
  34. Type: `Object`
  35. ##### spawn
  36. Type: `boolean`<br>
  37. Default: `true`
  38. Set to `false` to avoid spawning subprocesses and instead only resolve the locale from environment variables.
  39. ## Security
  40. To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
  41. ## License
  42. MIT © [Sindre Sorhus](https://sindresorhus.com)