index.ts.ftl 1.1 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
import Vue from 'vue'
import VueI18n from 'vue-i18n'

const vueApp: any = Vue;

vueApp.use(VueI18n);

import zhCn from './lang/zh-CN';
import vantZhCnLocale from 'vant/lib/locale/lang/zh-CN';

const messages = {
    'ZH-CN': Object.assign(vantZhCnLocale, zhCn),
};
<#if app.getAllPSAppLans()??>

<#list app.getAllPSAppLans() as lans>
<#if lans.getLanguage() == 'EN'>
import enUs from './lang/en-US';
import vantEnLocale from 'vant/lib/locale/lang/en-US';

Object.assign(messages, {
    'EN-US': Object.assign(vantEnLocale, enUs),
});
</#if>
</#list>
</#if>

// 自动根据浏览器系统语言设置语言
const navLang = localStorage.getItem('local') || navigator.language.toUpperCase();
const localLang = (navLang.indexOf('ZH') !== -1 || (navLang.indexOf('EN') !== -1 && messages.hasOwnProperty('EN-US'))) ? navLang : false;
let lang: string = localLang || 'ZH-CN';

vueApp.config.lang = lang

// // vue-i18n 6.x+写法
vueApp.locale = () => { };

const i18n = new VueI18n({
    locale: lang,
    messages
});

export default i18n;