import Vue from 'vue'
import VueI18n from 'vue-i18n'
// import EN from '@/lang/en/index.js'
// import CN from '@/lang/zn/index.js'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import enlogin from './lang/en/index.js'
import zhlogin from './lang/zn/index.js'
import locale from 'element-ui/lib/locale'

Vue.use(VueI18n)



const messages= {
  'en': Object.assign(enlogin, enLocale),
  'zh': Object.assign(zhlogin, zhLocale),
}

const i18n = new VueI18n({
  locale:  localStorage.getItem('lang') || navigator.language || 'en', // set locale
  fallbackLocale: 'en',
  silentFallbackWarn:true ,
  messages:messages,
  // 默认语言设置，当其他语言没有的情况下，使用en作为默认语言

})
// 配置elementUI 语言转换关系
locale.i18n((key, value) => i18n.t(key, value))

export default i18n
