forked from Mirrors/elk
fix: configure i18n locale from user preferences on load
This commit is contained in:
parent
d6d413a191
commit
da76c0076b
1 changed files with 6 additions and 0 deletions
|
@ -11,6 +11,12 @@ export default defineNuxtPlugin(async (nuxt) => {
|
|||
if (!supportLanguages.includes(lang))
|
||||
userSettings.value.language = getDefaultLanguage(supportLanguages)
|
||||
|
||||
if (lang !== i18n.locale) {
|
||||
setLocale(userSettings.value.language)
|
||||
// without this line, the locale not being refreshed on F5 and so the watch will change the locale twice
|
||||
i18n.locale = userSettings.value.language
|
||||
}
|
||||
|
||||
watch([$$(lang), isHydrated], () => {
|
||||
if (isHydrated.value && lang !== i18n.locale)
|
||||
setLocale(lang)
|
||||
|
|
Loading…
Reference in a new issue