It was built for streamlining the process of getting a default locale based on window.navigator.language
.
Abandoned - not utilized anywhere anymore, but code remains valid and could be used for reference.
const localeMapper = new LocaleMapper(navigator);
localeMapper.normalize(); // 'en-US'
localeMapper.normalize(true); // 'en', passing the "onlyLanguage" flag
localeMapper.fallback({
// explicit mapping
'de-DE': [
'de',
'de-DE',
'de-AT',
],
// another explicit mapping for the same family
'de-CH': [
'de-CH',
],
// language family wildcard
'es': [
'*',
],
// a wildcard with exclusion
'pt-PT': [
'*',
'!pt-BR',
],
});