zzzz
2024-04-16 273d548631148f99e17b6898d55a867a0ba93a25
src/i18n/index.js
@@ -1,80 +1,80 @@
// 引入必要的库
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Vue from "vue";
import VueI18n from "vue-i18n";
// 引入工具函数
import { getStorage } from '@/utils/utis'
import { getStorage } from "@/utils/utis";
// 引入项目中需要用到的中英文文案配置js
import enLocale from './en-US'
import cnLocale from './CN'
import zhcnLocale from './zh-CN'
import japcnLocale from './Jap'
import korcnLocale from './Korean'
import ThaiLocal from './Thai'
import SpanishLocal from './Spanish'
import deLocale from "./de"
import frenchLocale from "./French"
import indLocale from "./Indonesian";
import arLocale from "./ar";
import viLocale from "./vi";
import ItalyLocal from './Italy'
import enLocale from "./en.json";
import cnLocale from "./cht.json";
import zhcnLocale from "./zh.json";
import japcnLocale from "./jp.json";
import korcnLocale from "./kor.json";
import ThaiLocal from "./th.json";
import SpanishLocal from "./spa.json";
import deLocale from "./de.json";
import frenchLocale from "./fra.json";
import indLocale from "./id.json";
import arLocale from "./ara.json";
import viLocale from "./vie.json";
import ItalyLocal from "./it.json";
// 使用vue-i18n库
Vue.use(VueI18n)
Vue.use(VueI18n);
// 获取当前语言(初始化时localStorage里没有存语言,默认为浏览器当前的语言)
const lang = getStorage('lang')  || 'en'
const lang = getStorage("lang") || "en";
//const lang = 'zh-CN'
// 组合element ui 和 项目自身的文案文件
const messages = {
    'en': {
        ...enLocale
    },
    'CN': {
        ...cnLocale
    },
    'zh-CN': {
        ...zhcnLocale
    },
    'Japanese': {
        ...japcnLocale
    },
    'Korean': {
        ...korcnLocale
    },
    'th': {
        ...ThaiLocal
    },
    'es': {
        ...SpanishLocal
    },
    'de': {
        ...deLocale
    },
    'fr': {
        ...frenchLocale
    },
    'ind': {
        ...indLocale
    },
    'ar': {
        ...arLocale
    },
    'vi': {
        ...viLocale
    },
    'Italy': {
        ...ItalyLocal
    },
}
  en: {
    ...enLocale,
  },
  CN: {
    ...cnLocale,
  },
  "zh-CN": {
    ...zhcnLocale,
  },
  Japanese: {
    ...japcnLocale,
  },
  Korean: {
    ...korcnLocale,
  },
  th: {
    ...ThaiLocal,
  },
  es: {
    ...SpanishLocal,
  },
  de: {
    ...deLocale,
  },
  fr: {
    ...frenchLocale,
  },
  ind: {
    ...indLocale,
  },
  ar: {
    ...arLocale,
  },
  vi: {
    ...viLocale,
  },
  Italy: {
    ...ItalyLocal,
  },
};
// 创建vueI18n实例并输出,在main.js中调用
const i18n = new VueI18n({
    fallbackLocale: 'en',
    silentTranslationWarn: true,
    locale: lang,
    messages
})
  fallbackLocale: "en",
  silentTranslationWarn: true,
  locale: lang,
  messages,
});
export default i18n
export default i18n;