Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (locale) {
const [ lang, country ] = locale.split('_');
return { lang, country };
}
for (const { country, lang } of getBrowserLocales()) {
// $FlowFixMe
if (COUNTRY_LANGS.hasOwnProperty(country) && COUNTRY_LANGS[country].indexOf(lang) !== -1) {
// $FlowFixMe
return { country, lang };
}
}
for (const { country } of getBrowserLocales()) {
// $FlowFixMe
if (COUNTRY_LANGS.hasOwnProperty(country)) {
// $FlowFixMe
return { country, lang: COUNTRY_LANGS[country][0] };
}
}
return {
lang: LANG.EN,
country: COUNTRY.US
};
}
export function getLocale() : LocaleType {
const locale = getSDKQueryParam(SDK_QUERY_KEYS.LOCALE);
if (locale) {
const [ lang, country ] = locale.split('_');
return { lang, country };
}
for (const { country, lang } of getBrowserLocales()) {
// $FlowFixMe
if (COUNTRY_LANGS.hasOwnProperty(country) && COUNTRY_LANGS[country].indexOf(lang) !== -1) {
// $FlowFixMe
return { country, lang };
}
}
for (const { country } of getBrowserLocales()) {
// $FlowFixMe
if (COUNTRY_LANGS.hasOwnProperty(country)) {
// $FlowFixMe
return { country, lang: COUNTRY_LANGS[country][0] };
}
}
return {
lang: LANG.EN,
country: COUNTRY.US