From 71923d30dd062e8cdb5a4d95f89270e0556c60b4 Mon Sep 17 00:00:00 2001 From: userquin Date: Sat, 18 Feb 2023 02:53:24 +0100 Subject: [PATCH] chore: use await changing locale on initial load --- plugins/setup-i18n.client.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/setup-i18n.client.ts b/plugins/setup-i18n.client.ts index 1bd3e392..8cf007c0 100644 --- a/plugins/setup-i18n.client.ts +++ b/plugins/setup-i18n.client.ts @@ -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)