mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-13 16:42:01 +00:00
getInitialLocale now accepts navigatorLanguage as param
This commit is contained in:
parent
241e59dc98
commit
71fb19861d
@ -277,7 +277,7 @@ const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => {
|
|||||||
if (language) {
|
if (language) {
|
||||||
dispatch(WalletActions.fetchLocale(JSON.parse(language)));
|
dispatch(WalletActions.fetchLocale(JSON.parse(language)));
|
||||||
} else {
|
} else {
|
||||||
dispatch(WalletActions.fetchLocale(l10nUtils.getInitialLocale()));
|
dispatch(WalletActions.fetchLocale(l10nUtils.getInitialLocale(navigator.language)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const localCurrency: ?string = storageUtils.get(TYPE, KEY_LOCAL_CURRENCY);
|
const localCurrency: ?string = storageUtils.get(TYPE, KEY_LOCAL_CURRENCY);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { LANGUAGE } from 'config/app';
|
import { LANGUAGE } from 'config/app';
|
||||||
|
|
||||||
export const getInitialLocale = (defaultLocale = 'en') => {
|
export const getInitialLocale = (navigatorLanguage, defaultLocale = 'en') => {
|
||||||
const browserLocale = navigator.language.split('-')[0];
|
if (!navigatorLanguage) return defaultLocale;
|
||||||
|
|
||||||
|
const browserLocale = navigatorLanguage.split('-')[0];
|
||||||
if (LANGUAGE.some(e => e.code === browserLocale)) {
|
if (LANGUAGE.some(e => e.code === browserLocale)) {
|
||||||
// Array of supported languages contains the locale we're looking for
|
// Array of supported languages contains the locale we're looking for
|
||||||
return browserLocale;
|
return browserLocale;
|
||||||
|
Loading…
Reference in New Issue
Block a user