index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * @Author: From-wh from-wh@hotmail.com
  3. * @Date: 2023-03-09 18:02:23
  4. * @FilePath: /admin/src/i18n/index.js
  5. * @Description:
  6. */
  7. import Vue from 'vue';
  8. import VueI18n from 'vue-i18n';
  9. import zhcnLocale from 'element-ui/lib/locale/lang/zh-CN';
  10. import enLocale from 'element-ui/lib/locale/lang/en';
  11. import zhtwLocale from 'element-ui/lib/locale/lang/zh-TW';
  12. import store from '@/store/index.js';
  13. import nextZhcn from '@/i18n/lang/zh-cn.js';
  14. import nextEn from '@/i18n/lang/en.js';
  15. import nextZhtw from '@/i18n/lang/zh-tw.js';
  16. import pagesHomeZhcn from '@/i18n/pages/home/zh-cn.js';
  17. import pagesHomeEn from '@/i18n/pages/home/en.js';
  18. import pagesHomeZhtw from '@/i18n/pages/home/zh-tw.js';
  19. import pagesLoginZhcn from '@/i18n/pages/login/zh-cn.js';
  20. import pagesLoginEn from '@/i18n/pages/login/en.js';
  21. import pagesLoginZhtw from '@/i18n/pages/login/zh-tw.js';
  22. import iviewZhCnLocale from 'iview/src/locale/lang/zh-CN';
  23. import iviewEnUsLocale from 'iview/src/locale/lang/en-US';
  24. import iviewZhTwLocale from 'iview/src/locale/lang/zh-TW';
  25. // 使用插件
  26. Vue.use(VueI18n);
  27. // 定义语言国际化内容
  28. /**
  29. * 说明:
  30. * /src/i18n/lang 下的 js 为框架的国际化内容
  31. * /src/i18n/pages 下的 js 为各界面的国际化内容
  32. */
  33. const messages = {
  34. 'zh-cn': {
  35. ...zhcnLocale,
  36. ...iviewZhCnLocale,
  37. message: {
  38. ...nextZhcn,
  39. ...pagesHomeZhcn,
  40. ...pagesLoginZhcn,
  41. },
  42. },
  43. en: {
  44. ...enLocale,
  45. ...iviewEnUsLocale,
  46. message: {
  47. ...nextEn,
  48. ...pagesHomeEn,
  49. ...pagesLoginEn,
  50. },
  51. },
  52. 'zh-tw': {
  53. ...zhtwLocale,
  54. ...iviewZhTwLocale,
  55. message: {
  56. ...nextZhtw,
  57. ...pagesHomeZhtw,
  58. ...pagesLoginZhtw,
  59. },
  60. },
  61. };
  62. // 导出语言国际化
  63. export const i18n = new VueI18n({
  64. locale: store.state.themeConfig.themeConfig.globalI18n,
  65. fallbackLocale: 'zh-cn',
  66. messages,
  67. silentTranslationWarn: true, // 去除国际化警告
  68. });