element-ui 中英文切换
转载声明:
本文为摘录自“csdn博客”,版权归原作者所有。
温馨提示:
为了更好的体验,请点击原文链接进行浏览
摘录时间:
2021-02-24 17:26:12
import VueI18n from 'vue-i18n'
import ElementUI from 'element-ui'
import ElementLocale from 'element-ui/lib/locale'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import Cookies from 'js-cookie'
import lang from '@/common/lang' // 中英文翻译
Vue.use(ElementUI);
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: Cookies.get('language') || 'en', // 语言标识
messages: {
en: {
...lang.en,
...enLocale
},
zh: {
...lang.zh,
...zhLocale
}
}
});
Cookies.set('language',i18n.locale);
ElementLocale.i18n((key, value) => i18n.t(key, value))
原文:https://blog.csdn.net/github_37793365/article/details/83865237