vdpAdmin f7885d5774 1. 替换vue-i18n多语言实现;
2. 修复一丢丢小问题。
2022-02-11 17:31:36 +08:00

67 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
},
}
}