refactor(i18n):重命名文件并优化国际化插件代码

- 将 i18n.ts 重命名为 i18n.js,统一文件类型
- 移除了未使用的类型导入 TypeLocale
- 添加了对 vant国际化语言包的导入- 简化了 setLocale 调用,移除了不必要的类型转换
- 优化了代码格式和注释
This commit is contained in:
xingyy 2025-01-23 14:25:30 +08:00
parent 0d1342414b
commit 579c6df57b
4 changed files with 3 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import type { Locale as TypeLocale } from '#i18n'
import { Locale } from 'vant' import { Locale } from 'vant'
import enUS from 'vant/es/locale/lang/en-US' import enUS from 'vant/es/locale/lang/en-US'
import zhCN from 'vant/es/locale/lang/zh-CN' import zhCN from 'vant/es/locale/lang/zh-CN'
@ -6,7 +6,7 @@ import jaJP from 'vant/es/locale/lang/ja-JP'
import zhTW from 'vant/es/locale/lang/zh-TW' import zhTW from 'vant/es/locale/lang/zh-TW'
export default defineNuxtPlugin(() => { export default defineNuxtPlugin(() => {
// 载入 vant 语言包
Locale.use('zh-CN', zhCN) Locale.use('zh-CN', zhCN)
Locale.use('en-US', enUS) Locale.use('en-US', enUS)
Locale.use('ja-JP', jaJP) Locale.use('ja-JP', jaJP)
@ -15,11 +15,9 @@ export default defineNuxtPlugin(() => {
if (import.meta.client) { if (import.meta.client) {
const i18n = useNuxtApp().$i18n const i18n = useNuxtApp().$i18n
const { setLocale } = i18n const { setLocale } = i18n
const lang = localStorage.getItem('lang') const lang = localStorage.getItem('lang')
if (lang) { if (lang) {
setLocale(lang as TypeLocale) setLocale(lang)
Locale.use(lang) Locale.use(lang)
} }
else { else {