index.js 516 字节
Newer Older
Q
qiang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
const { I18n } = require('i18n')
const { format } = require('./lang')

const defaultLocale = format(process.env.UNI_HBUILDERX_LANGID || process.env.LANG)

const i18n = new I18n()

const staticCatalog = {}

// 暂时仅支持 en、zh_CN
const locales = [
  'en',
  // 'es',
  // 'fr',
  // 'zh_HK',
  'zh_CN'
]

locales.forEach(item => {
  // TODO 合并 HBuilderX 内置内容
  staticCatalog[item] = require(`../locales/${item}.json`)
})

i18n.configure({
  staticCatalog,
  defaultLocale
})

module.exports = i18n