Skip to content

SeregPie/detectNearestLocale

Repository files navigation

detectNearestLocale

detectNearestLocale(supportedLocales, preferredLocales)

Detects the nearest preferred locale.

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

see also

About

Detects the nearest preferred locale.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published