1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import Vue from 'vue';
- import VueI18n from 'vue-i18n';
- import store from '../store';
- import { getStaticContent } from '@/api/api';
- import ElementLocale from 'element-ui/lib/locale';
- import zhLocal from 'element-ui/lib/locale/lang/zh-CN';
- import arLocal from 'element-ui/lib/locale/lang/ar';
- import enLocal from 'element-ui/lib/locale/lang/en';
- import jaLocal from 'element-ui/lib/locale/lang/ja';
- import deLocal from 'element-ui/lib/locale/lang/de';
- import ruLocal from 'element-ui/lib/locale/lang/ru-RU';
- Vue.use(VueI18n);
- const i18n = new VueI18n({
- locale: localStorage.getItem('language_type') || "ZH", //store.getters.language_type,
- messages: {
- ZH: {
- ...zhLocal
- },
- AR: {
- ...arLocal
- },
- EN: {
- ...enLocal
- },
- JA: {
- ...jaLocal
- },
- DE: {
- ...deLocal
- },
- RU: {
- ...ruLocal
- }
- },
- silentTranslationWarn: true
- });
- ElementLocale.i18n((key, value) => i18n.t(key, value));
- export async function setI18nLang(language_type) {
- console.log(language_type);
- await store.dispatch('lang/updateLanguageType', language_type);
- }
- /**
- * @description 更新语言列表
- * @param {Object} Parameter word_key_list 需要读取的词汇
- */
- export function updateWordPack(Parameter) {
- Parameter.language_type = store.getters.language_type;
- let MethodName = 'language_manager-GetWordPack';
- getStaticContent(MethodName, Parameter).then(data => {
- let localWord = i18n.messages[data.language_type];
- if (localWord === undefined) {
- localWord = {};
- }
- let wordPack = Object.assign(localWord, data.word_pack);
- i18n.setLocaleMessage(data.language_type, wordPack);
- // localStorage.setItem('i18n-message', JSON.stringify(i18n.messages));
- });
- }
- export default i18n;
|