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
let locale = detectNearestBrowserLocale(['ru', 'en-US']);