Files
mes-ui-d2/src/i18n.js
liyang 7e5bd78fdb add i18n
Former-commit-id: e40632a3129a3147d4692474f05fcac1a8fb05da [formerly e40632a3129a3147d4692474f05fcac1a8fb05da [formerly e40632a3129a3147d4692474f05fcac1a8fb05da [formerly e40632a3129a3147d4692474f05fcac1a8fb05da [formerly 8a560e505164fe5718e1f386ecd8c84d213726b1 [formerly 0582bf632cbd9db5164fb2c454399fd1bd64ba41]]]]]
Former-commit-id: d0e35c73fc91d65ac612adf939e15f2c05a6dc1f
Former-commit-id: e6f9e3c3173dc757fd348cfc493055cdf4ed55a7
Former-commit-id: 3ea8c7bf97ab2e1b91986c7cd1a92da4200ecbc0 [formerly f4ffd12918a98e51b9f5f53a0102254e12ccc634]
Former-commit-id: 5eddfc5487865adcbef1d176ab1fabf305614efc
Former-commit-id: 044b0bf737fed573bd305b036c236b0a227bf0e1
Former-commit-id: f85fe58ea89d29b4579023de9829347012d29bc6
Former-commit-id: c91fbfc5efab828f43c8c51216c604a3987973b4
Former-commit-id: d96ee1048ea756123890a74af896b14a851c375d
2019-05-21 23:51:29 +08:00

24 lines
623 B
JavaScript

import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
function loadLocaleMessages () {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
const messages = {}
locales.keys().forEach(key => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
if (matched && matched.length > 1) {
const locale = matched[1]
messages[locale] = locales(key)
}
})
return messages
}
export default new VueI18n({
locale: process.env.VUE_APP_I18N_LOCALE || 'en',
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en',
messages: loadLocaleMessages()
})