Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_getViaQueryString (definedLocales, allowedLocales) {
if (typeof (definedLocales) === 'string' && definedLocales.length) {
const detectedLocale = preferredLanguages(definedLocales, allowedLocales)
return detectedLocale instanceof Array ? detectedLocale[0] : detectedLocale
}
return null
}
getLocale() {
let availableLanguages = [];
if (Array.isArray(navigator.languages)) {
availableLanguages = navigator.languages;
} else
if (navigator.language) {
availableLanguages = [navigator.language];
}
const languages = preferredLanguages(availableLanguages.join(','), Object.keys(this.localeMap));
let locale = this.localeMap[this.defaultLocale];
if (languages) {
locale = Object.assign({}, locale, this.localeMap[languages[0]]);
}
return locale;
}
};