import { createI18n } from 'vue-i18n';
import { navigatorLanguage } from '../common/js/utils';
// 引入英文语言包
import enUS from 'vant/es/locale/lang/en-US';
// 引入简体中文语言包
import zhCN from 'vant/es/locale/lang/zh-CN';
let language = 'en';
// 储存语言，方便中英切换
const curLang = localStorage.getItem('curLang');
if (curLang) {
    language = curLang;
    localStorage.setItem('curLang', curLang);
} else {
    language = navigatorLanguage();
    localStorage.setItem('curLang', navigatorLanguage());
}
// vant组件的中英文切换
import { Locale } from 'vant';
// 判断中英文，切换vant语言包
if (language === 'en') {
    Locale.use('en-US', enUS);
} else {
    Locale.use('zh-CN', zhCN);
}
export default createI18n({
    //多语言实例
    legacy: false,
    globalInjection: true,
    // 默认语言
    locale: localStorage.getItem('curLang'),
    // 关闭控制台警告
    silentFallbackWarn: true,
    messages: {
        'en': require('../assets/language/en.json'), //英文包
        'zh': require('../assets/language/zh.json'), //中文包
    }
});