add:增加语言包依赖

This commit is contained in:
zhangzq
2025-10-14 17:17:28 +08:00
parent 3245f4dd32
commit 9a85d1bd73
21 changed files with 1491 additions and 593 deletions

View File

@@ -1,27 +1,19 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import locale from 'element-ui/lib/locale'
import zh from './langs/chinese'
import en from './langs/english'
import indonesian from './langs/indonesian'
Vue.use(VueI18n)
const messages = {
en: {
...en
},
zh: {
...zh
},
in: {
...indonesian
}
}
// 准备默认的语言环境消息(可以是空对象,也可以是一些基本消息)
const defaultLocale = 'zh'
const fallbackLocale = 'zh'
// 创建i18n实例
const i18n = new VueI18n({
locale: localStorage.lang || 'zh',
messages,
locale: defaultLocale, // 设置当前语言
fallbackLocale, // 设置回退语言
silentTranslationWarn: true, // 解决vue-i18n黄色警告"value of key 'xxx' is not a string"和"cannot translate the value of keypath 'xxx'.use the value of keypath as default",可忽略
globalInjection: true, // 全局注入
fallbackLocale: 'zh'
globalInjection: true,
messages: {} // 初始化为空,稍后从接口获取
})
locale.i18n((key, value) => i18n.t(key, value))
export default i18n