Elementコントロールの英語翻訳、

756 ワード


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