fix(i18n): fall back to browser language if the configured user language is invalid
This commit is contained in:
parent
58a1f46668
commit
a9fb306e46
@ -47,8 +47,13 @@ export async function setLanguage(lang: SupportedLocale): Promise<SupportedLocal
|
||||
|
||||
// If the language hasn't been loaded yet
|
||||
if (!i18n.global.availableLocales.includes(lang)) {
|
||||
try {
|
||||
const messages = await import(`./lang/${lang}.json`)
|
||||
i18n.global.setLocaleMessage(lang, messages.default)
|
||||
} catch (e) {
|
||||
console.error(`Failed to load language ${lang}:`, e)
|
||||
return setLanguage(getBrowserLanguage())
|
||||
}
|
||||
}
|
||||
|
||||
i18n.global.locale.value = lang
|
||||
|
Loading…
x
Reference in New Issue
Block a user