mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-02 21:28:12 +00:00
14 lines
496 B
JavaScript
14 lines
496 B
JavaScript
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;
|
|
};
|