🐞 fix: 可能使用不存在的语言

This commit is contained in:
m1m1sha 2024-05-06 09:05:40 +08:00
parent e7092bfcf6
commit 893fba4adf

View File

@ -35,7 +35,14 @@ export async function loadLanguageAsync(lang: string): Promise<Locale> {
return setI18nLanguage(lang)
// If the language hasn't been loaded yet
const messages = await localesMap[lang]()
let messages;
try {
messages = await localesMap[lang]()
} catch {
messages = await localesMap['en']()
}
i18n.global.setLocaleMessage(lang, messages.default)
loadedLanguages.push(lang)
return setI18nLanguage(lang)