detect-nearest-locale
v1.0.1
Published
Detects the nearest preferred locale.
Downloads
666
Readme
detectNearestLocale
detectNearestLocale(supportedLocales, preferredLocales)
Detects the nearest preferred locale.
| argument | description |
| ---: | :--- |
| supportedLocales
| An array of supported locales. |
| preferredLocales
| An array of preferred locales. |
Returns the first matching supported locale.
setup
npm
npm i detect-nearest-locale
ES module
import detectNearestLocale from 'detect-nearest-locale';
browser
<script src="https://unpkg.com/detect-nearest-locale"></script>
usage
let locale = detectNearestLocale(['ru', 'en-US'], ['de', 'en-GB']);
// => 'en-US'