import Vue from 'vue';
import VueI18n from 'vue-i18n';
import enLocale from '@/api/language/language.en_US'
import usLocal from '@/api/language/language.zh_CN'
import Vietnam from '@/api/language/language.vi'
import twLocal from '@/api/language/language.zh_TW'
// element-ui 组件国际化
import ElementLocale from 'element-ui/lib/locale'
import elementEnLocal from "element-ui/lib/locale/lang/en"
import elementZhCNLocal from "element-ui/lib/locale/lang/zh-CN"
import elementVietnam from "element-ui/lib/locale/lang/vi"
import elementZhTWLocal from "element-ui/lib/locale/lang/zh-TW"
ElementLocale.i18n((key, value) => i18n.t(key, value))

Vue.use(VueI18n);
const messages = {
  en_US: {
    ...enLocale,
    ...elementEnLocal
  },
  zh_CN: {
    ...usLocal,
    ...elementZhCNLocal
  },
  zh_TW: {
    ...twLocal,
    ...elementZhTWLocal
  },
  vi: {
    ...Vietnam,
    ...elementVietnam
  }
}
const i18n = new VueI18n({
  locale: localStorage.getItem('lang') || 'zh_TW', // 通过this.$i18n.locale的值实现语言切换
  messages,
});


export default i18n;
