配置多语言
This commit is contained in:
5
src/lang/en.ts
Normal file
5
src/lang/en.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
Login: {
|
||||
|
||||
},
|
||||
}
|
||||
31
src/lang/index.ts
Normal file
31
src/lang/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
// 中文 zh-cn
|
||||
// 英文 en
|
||||
|
||||
// element-plus 中的语言配置
|
||||
import elementEnLocale from './en'
|
||||
|
||||
// 自己的语言配置
|
||||
import enLocale from './en'
|
||||
|
||||
// 语言配置整合
|
||||
const messages = {
|
||||
'ENGLISH':{
|
||||
...enLocale,
|
||||
...elementEnLocale
|
||||
},
|
||||
// 'CHINESE_SIMPLIFIED':{
|
||||
// ...zhLocale,
|
||||
// ...elementZhLocale
|
||||
// },
|
||||
}
|
||||
|
||||
// 创建 i18n
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
globalInjection:true, // 全局模式,可以直接使用 $t
|
||||
locale: 'ENGLISH',
|
||||
messages: messages
|
||||
})
|
||||
|
||||
export default i18n
|
||||
@@ -7,6 +7,7 @@ import './assets/css/style.css'
|
||||
import SvgIcon from "@/components/SvgIcon/index.vue";
|
||||
import "virtual:svg-icons-register";
|
||||
|
||||
import i18n from "./lang/index";
|
||||
|
||||
import flexible from "./utils/flexible.js";
|
||||
|
||||
@@ -19,6 +20,7 @@ app.use(router)
|
||||
.use(ElementPlus)
|
||||
.use(store)
|
||||
.component("SvgIcon", SvgIcon)
|
||||
.use(i18n)
|
||||
.mount('#app')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user