0
0
Fork 0

存在しない言語名が設定されている場合、初期化するように

This commit is contained in:
Xeltica 2022-06-23 00:14:06 +09:00
parent 334037b161
commit 44dff73b24

View file

@ -5,7 +5,7 @@ import dayjs from 'dayjs';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import { getBrowserLanguage, resources } from './langs';
import { getBrowserLanguage, languageName, resources } from './langs';
import { App } from './App';
import { LOCALSTORAGE_KEY_LANG } from './const';
@ -17,7 +17,7 @@ dayjs.extend(relativeTime);
let lng = localStorage[LOCALSTORAGE_KEY_LANG];
if (!lng) {
if (!lng || !Object.keys(languageName).includes(lng)) {
lng = localStorage[LOCALSTORAGE_KEY_LANG] = getBrowserLanguage();
}