fix: do not change language to the current one

This commit is contained in:
Dominik Pschenitschni 2022-10-24 18:59:04 +02:00 committed by kolaente
parent b8cc828bc0
commit abc26496cf
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 8 additions and 9 deletions

View File

@ -49,18 +49,17 @@ export async function loadLanguageAsync(lang: SupportedLocale) {
throw new Error() throw new Error()
} }
if ( // do not change language to the current one
// If the same language if (i18n.global.locale === lang) {
i18n.global.locale === lang || return
// If the language was already loaded
i18n.global.availableLocales.includes(lang)
) {
return setI18nLanguage(lang)
} }
// If the language hasn't been loaded yet // If the language hasn't been loaded yet
const messages = await import(`./lang/${lang}.json`) if (!i18n.global.availableLocales.includes(lang)) {
i18n.global.setLocaleMessage(lang, messages.default) const messages = await import(`./lang/${lang}.json`)
i18n.global.setLocaleMessage(lang, messages.default)
}
return setI18nLanguage(lang) return setI18nLanguage(lang)
} }