language.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import axios from 'axios'
  2. import zhCN from '@public/locales/zh-CN.json'
  3. import enUS from '@public/locales/en-US.json'
  4. import thTH from '@public/locales/th-TH.json'
  5. import zhTW from '@public/locales/zh-TW.json'
  6. import viVN from '@public/locales/vi-VN.json'
  7. import { Language } from '@/constants/language'
  8. import { createI18n } from 'vue-i18n'
  9. import { localData } from '../storage'
  10. export const i18n = createI18n({
  11. locale: localData.getValue('appLanguage'),
  12. fallbackLocale: Language.English,
  13. messages: {
  14. [Language.Simplified]: zhCN,
  15. [Language.Traditional]: zhTW,
  16. [Language.English]: enUS,
  17. [Language.Thai]: thTH,
  18. [Language.VI]: viVN,
  19. }
  20. })
  21. axios('./locales/extras/zh-CN.json').then((res) => {
  22. i18n.global.mergeLocaleMessage(Language.Simplified, res.data)
  23. })
  24. axios('./locales/extras/zh-TW.json').then((res) => {
  25. i18n.global.mergeLocaleMessage(Language.Traditional, res.data)
  26. })
  27. axios('./locales/extras/en-US.json').then((res) => {
  28. i18n.global.mergeLocaleMessage(Language.English, res.data)
  29. })
  30. axios('./locales/extras/th-TH.json').then((res) => {
  31. i18n.global.mergeLocaleMessage(Language.Thai, res.data)
  32. })
  33. axios('./locales/extras/vi-VN.json').then((res) => {
  34. i18n.global.mergeLocaleMessage(Language.VI, res.data)
  35. })