import { createI18n } from 'vue-i18n'
import en from '../locales/en.json'
import zhCN from '../locales/zh-CN.json'

let language = window.localStorage.getItem('currentLanguage') || 'en'
if (language !== 'zh-CN' && language !== 'en') {
  language = 'en'
}

const i18n = createI18n({
  // something vue-i18n options here ...
  legacy: false,
  // locale: language === 'zh-CN' ? 'zh-CN' : 'en', // 根据浏览器语言设置
  locale: language,
  fallbackLocale: 'en',
  messages: {
    en,
    'zh-CN': zhCN
  }
})

export default i18n
