Skip to content

exlinc/detectNearestBrowserLocale

 
 

Repository files navigation

detectNearestBrowserLocale

detectNearestBrowserLocale(supportedLocales)

Detects nearest browser locale.

argument description
supportedLocales An array of supported locales.

Returns the first matching supported locale.

dependencies

no dependencies

setup

npm

npm install detect-nearest-browser-locale

ES module

import detectNearestBrowserLocale from 'detect-nearest-browser-locale';

browser

<script src="https://unpkg.com/detect-nearest-browser-locale"></script>

usage

// navigator.languages => ['de-DE', 'en-US', 'en-GB']
let locale = detectNearestBrowserLocale(['ru', 'en']);
// => 'en'

About

Detects the nearest browser locale.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%