You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
618 B
24 lines
618 B
4 years ago
|
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-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()
|
||
|
})
|