fix: configure i18n locale from user preferences on load

This commit is contained in:
userquin 2023-02-18 01:25:03 +01:00
parent d6d413a191
commit da76c0076b

View file

@ -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)