local-util.ts 896 字节
Newer Older
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
export const localList: any[] = [
    {
        type: 'zh-CN',
        name: '中文简体',
    },
    {
        type: 'en-US',
        name: 'English',
    },
];

/**
 * 多语言翻译
 */
export const translate: Function = (key: string, context: any, value?: string) => {
    if (context && context.$te && context.$te(key)) {
        return context.$t(key);
    } else {
        if (context.modelService) {
            const lanResource: any = context.modelService.getPSLang(key);
            return lanResource ? lanResource : value ? value : key;
        } else {
            return value ? value : key;
        }
    }
}

/**
 * 处理语言路径映射
 *
 */
export const handleLocaleMap: Function = (key: string) => {
    switch (key) {
        case 'zh-CN':
            return 'ZH_CN';
        case 'en-US':
            return 'EN';
        default:
            return 'ZH_CN';
    }
}