存在しない言語名が設定されている場合、初期化するように
This commit is contained in:
parent
334037b161
commit
44dff73b24
1 changed files with 2 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue