index.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { createI18n } from 'vue-i18n';
  2. import zhcnLocale from 'element-plus/lib/locale/lang/zh-cn';
  3. import enLocale from 'element-plus/lib/locale/lang/en';
  4. import zhtwLocale from 'element-plus/lib/locale/lang/zh-tw';
  5. import { store } from '/@/store/index';
  6. import nextZhcn from '/@/i18n/lang/zh-cn';
  7. import nextEn from '/@/i18n/lang/en';
  8. import nextZhtw from '/@/i18n/lang/zh-tw';
  9. import pagesLoginZhcn from '/@/i18n/pages/login/zh-cn';
  10. import pagesLoginEn from '/@/i18n/pages/login/en';
  11. import pagesLoginZhtw from '/@/i18n/pages/login/zh-tw';
  12. import pagesFormI18nZhcn from '/@/i18n/pages/formI18n/zh-cn';
  13. import pagesFormI18nEn from '/@/i18n/pages/formI18n/en';
  14. import pagesFormI18nZhtw from '/@/i18n/pages/formI18n/zh-tw';
  15. // 定义语言国际化内容
  16. /**
  17. * 说明:
  18. * /src/i18n/lang 下的 ts 为框架的国际化内容
  19. * /src/i18n/pages 下的 ts 为各界面的国际化内容
  20. */
  21. const messages = {
  22. [zhcnLocale.name]: {
  23. ...zhcnLocale,
  24. message: {
  25. ...nextZhcn,
  26. ...pagesLoginZhcn,
  27. ...pagesFormI18nZhcn,
  28. },
  29. },
  30. [enLocale.name]: {
  31. ...enLocale,
  32. message: {
  33. ...nextEn,
  34. ...pagesLoginEn,
  35. ...pagesFormI18nEn,
  36. },
  37. },
  38. [zhtwLocale.name]: {
  39. ...zhtwLocale,
  40. message: {
  41. ...nextZhtw,
  42. ...pagesLoginZhtw,
  43. ...pagesFormI18nZhtw,
  44. },
  45. },
  46. };
  47. // 导出语言国际化
  48. export const i18n = createI18n({
  49. locale: store.state.themeConfig.themeConfig.globalI18n,
  50. fallbackLocale: zhcnLocale.name,
  51. messages,
  52. });