You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/utils/l10n.js

14 lines
496 B

import { LANGUAGE } from 'config/app';
export const getInitialLocale = (navigatorLanguage, defaultLocale = 'en') => {
if (!navigatorLanguage) return defaultLocale;
const browserLocale = navigatorLanguage.split('-')[0];
if (LANGUAGE.some(e => e.code === browserLocale)) {
// Array of supported languages contains the locale we're looking for
return browserLocale;
}
// if browser lang is not supported return en as default locale
return defaultLocale;
};