Skip to content

SeregPie/detectNearestBrowserLocale

Repository files navigation

detectNearestBrowserLocale

detectNearestBrowserLocale(supportedLocales)

Detects the nearest browser locale.

argument description
supportedLocales An array of the 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'

Releases

No releases published

Packages

No packages published