mirror of
https://github.com/vform666/variant-form3-vite.git
synced 2025-05-10 18:24:36 +08:00
67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
import { createI18n } from './smart-vue-i18n/index'
|
||
|
||
import enLocaleElement from "element-plus/lib/locale/lang/en";
|
||
import zhLocaleElement from "element-plus/lib/locale/lang/zh-cn";
|
||
//import locale from "element-plus/lib/locale"
|
||
|
||
import enLocale from "@/lang/en-US";
|
||
import zhLocale from "@/lang/zh-CN";
|
||
import enLocale_render from "@/lang/en-US_render";
|
||
import zhLocale_render from "@/lang/zh-CN_render";
|
||
import enLocale_extension from "@/lang/en-US_extension";
|
||
import zhLocale_extension from "@/lang/zh-CN_extension";
|
||
|
||
const langResources = {
|
||
'en-US': {
|
||
something: {
|
||
//...
|
||
},
|
||
...enLocaleElement,
|
||
...enLocale,
|
||
...enLocale_render,
|
||
...enLocale_extension
|
||
},
|
||
|
||
'zh-CN': {
|
||
something: {
|
||
//...
|
||
},
|
||
...zhLocaleElement,
|
||
...zhLocale,
|
||
...zhLocale_render,
|
||
...zhLocale_extension
|
||
}
|
||
}
|
||
|
||
const i18n = createI18n({
|
||
locale: localStorage.getItem('v_form_locale') || 'zh-CN',
|
||
messages: langResources
|
||
})
|
||
|
||
export const changeLocale = function(langName) {
|
||
i18n.setLang(langName)
|
||
localStorage.setItem('v_form_locale', langName)
|
||
}
|
||
|
||
export const translate = function(key) {
|
||
return i18n.$st(key)
|
||
}
|
||
|
||
export const installI18n = (app) => {
|
||
//
|
||
}
|
||
|
||
export default {
|
||
methods: {
|
||
i18nt(key) {
|
||
return i18n.$st(key)
|
||
},
|
||
|
||
/* 如果key1不存在,则查找key2 */
|
||
i18n2t(key1, key2) {
|
||
return i18n.$st2(key1, key2)
|
||
},
|
||
|
||
}
|
||
}
|