chore: use await changing locale on initial load

This commit is contained in:
userquin 2023-02-18 02:53:24 +01:00
parent 8fe904d0b5
commit 71923d30dd

View file

@ -11,11 +11,8 @@ 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
}
if (lang !== i18n.locale)
await setLocale(userSettings.value.language)
watch([$$(lang), isHydrated], () => {
if (isHydrated.value && lang !== i18n.locale)