1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-12 11:28:56 +00:00
trezor-wallet/src/utils/l10n.js

14 lines
496 B
JavaScript
Raw Normal View History

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;
2019-03-04 12:33:02 +00:00
};