chore: use latest i18n v9 (#3059)
This commit is contained in:
parent
e6ebde3ac4
commit
f4b667fef6
10 changed files with 313 additions and 332 deletions
|
@ -1,3 +1,5 @@
|
|||
import type { Locale } from '#i18n'
|
||||
|
||||
export default defineNuxtPlugin(async (nuxt) => {
|
||||
const t = nuxt.vueApp.config.globalProperties.$t
|
||||
const d = nuxt.vueApp.config.globalProperties.$d
|
||||
|
@ -11,14 +13,14 @@ export default defineNuxtPlugin(async (nuxt) => {
|
|||
const i18n = useNuxtApp().$i18n
|
||||
const { setLocale, locales } = i18n
|
||||
const userSettings = useUserSettings()
|
||||
const lang = computed(() => userSettings.value.language)
|
||||
const lang = computed(() => userSettings.value.language as Locale)
|
||||
|
||||
const supportLanguages = unref(locales).map(locale => locale.code)
|
||||
if (!supportLanguages.includes(lang.value))
|
||||
userSettings.value.language = getDefaultLanguage(supportLanguages)
|
||||
|
||||
if (lang.value !== i18n.locale)
|
||||
await setLocale(userSettings.value.language)
|
||||
await setLocale(userSettings.value.language as Locale)
|
||||
|
||||
watch([lang, isHydrated], () => {
|
||||
if (isHydrated.value && lang.value !== i18n.locale)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue