index.js 585 B

123456789101112131415161718192021222324252627282930313233
  1. import enUS from './en_US.json'
  2. import thTH from './th_TH.json'
  3. import zhCN from './zh_CN.json'
  4. import { createI18n } from 'vue-i18n'
  5. import storage from "@/utils/storage.js"
  6. const lang = storage.getCache('lang')
  7. const defaultLocale = lang || 'zh_cn'
  8. export const i18nConfig = {
  9. locale: defaultLocale,
  10. messages: {
  11. 'en_us': enUS,
  12. 'th_th': thTH,
  13. 'zh_cn': zhCN,
  14. },
  15. }
  16. const i18n = createI18n(i18nConfig)
  17. export const t = i18n.global.t
  18. export function setLocale(locale) {
  19. i18n.global.locale = locale
  20. }
  21. export function setupI18n(app) {
  22. app.use(i18n)
  23. }
  24. export default i18n