lang.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import en_us from '../lang/en_us.json'
  2. import zh_cn from '../lang/zh_cn.json'
  3. import fr_fr from '../lang/fr_fr.json'
  4. import th_th from '../lang/th_th.json'
  5. import ja_jp from '../lang/ja_jp.json'
  6. import it_it from '../lang/it_it.json'
  7. import ko_kr from '../lang/ko_kr.json'
  8. import mn_mn from '../lang/mn_mn.json'
  9. import vi_vn from '../lang/vi_vn.json'
  10. import zh_ft from '../lang/zh_ft.json'
  11. import Vue from 'vue';
  12. import VueI18n from 'vue-i18n'
  13. Vue.use(VueI18n)
  14. let langJson = {
  15. 'en_us': en_us,
  16. 'zh_cn': zh_cn,
  17. 'fr_fr': fr_fr,
  18. 'th_th': th_th,
  19. 'ja_jp': ja_jp,
  20. 'it_it': it_it,
  21. 'ko_kr': ko_kr,
  22. 'mn_mn': mn_mn,
  23. 'vi_vn': vi_vn,
  24. 'zh_ft': zh_ft,
  25. }
  26. let lang = '';
  27. // #ifdef MP || APP-PLUS
  28. lang = uni.getStorageSync('locale') != '' ? uni.getStorageSync('locale') : 'zh_cn';
  29. // #endif
  30. // #ifdef H5
  31. lang = uni.getStorageSync('locale') != '' ? uni.getStorageSync('locale') : navigator.language.toLowerCase().replace('-','_');
  32. // #endif
  33. const i18n = new VueI18n({
  34. locale: lang in langJson ? lang :'en_us',
  35. messages: langJson
  36. })
  37. export default i18n