index.ts.ftl 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<#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 iviewZhCnLocale from 'view-design/dist/locale/zh-CN';
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN';

const messages = {
16
    'zh-CN': Object.assign(iviewZhCnLocale, elementZhLocale, zhCn()),
17 18 19 20 21 22 23 24 25 26
};
<#if app.getAllPSAppLans()??>

<#list app.getAllPSAppLans() as lans>
<#if lans.getLanguage() == 'EN'>
import enUs from './lang/en-US';
import iviewEnUsLocale from 'view-design/dist/locale/en-US';
import elementEnLocale from 'element-ui/lib/locale/lang/en';

Object.assign(messages, {
27
    'en-US': Object.assign(iviewEnUsLocale, elementEnLocale, enUs()),
28 29
});
</#if>
RedPing97's avatar
RedPing97 committed
30
<#if lans.getLanguage() == 'BO_CN'>
31 32 33
import BOCn from './lang/BO-CN';
import iviewBOCnLocale from './other/iview/BO-CN'
import elementBOLocale from './other/element/BO-CN'
34
Object.assign(messages, {
35
    'BO-CN': Object.assign(iviewBOCnLocale,elementBOLocale,BOCn()),
36 37
});
</#if>
38 39 40 41 42
</#list>
</#if>

// 自动根据浏览器系统语言设置语言
const navLang = localStorage.getItem('local') || navigator.language;
RedPing97's avatar
RedPing97 committed
43
const localLang = (navLang === 'zh-CN' || (navLang === 'en-US' && messages.hasOwnProperty('en-US')) || (navLang === 'ti-US' && messages.hasOwnProperty('ti-US'))) ? navLang : false;
44 45 46 47 48 49 50 51 52
let lang: string = localLang || 'zh-CN';

vueApp.config.lang = lang

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

const i18n = new VueI18n({
    locale: lang,
tony001's avatar
tony001 committed
53 54
    messages,
    silentTranslationWarn:true
55 56 57
});

export default i18n;