detect-nearest-browser-locale
v19.0.0
Published
Detects the nearest browser locale.
Downloads
616
Maintainers
Readme
detectNearestBrowserLocale
detectNearestBrowserLocale(supportedLocales)
Detects the nearest browser locale.
| argument | description |
| ---: | :--- |
| supportedLocales
| An array of supported locales. |
Returns the first matching supported locale.
dependencies
setup
npm
npm i detect-nearest-browser-locale
ES module
import detectNearestBrowserLocale from 'detect-nearest-browser-locale';
browser
<script src="https://unpkg.com/detect-nearest-locale"></script>
<script src="https://unpkg.com/detect-nearest-browser-locale"></script>
usage
// navigator.languages => ['de', 'en-GB']
let locale = detectNearestBrowserLocale(['ru', 'en-US']);
// => 'en-US'