Former-commit-id: 81ed749f0cc0919e3560d59536a7a2bfb3d32cec [formerly 81ed749f0cc0919e3560d59536a7a2bfb3d32cec [formerly 81ed749f0cc0919e3560d59536a7a2bfb3d32cec [formerly 81ed749f0cc0919e3560d59536a7a2bfb3d32cec [formerly efed8ea3185d767af26a8c7ac0022056443ccddf [formerly d2ef4da90c85f2aaffe40ad9582961b86fcf79e6]]]]] Former-commit-id: dafb9ad722dc1cbfafbe7e935de82bce4c332178 Former-commit-id: 0af9a05e9e579c3c65a39c0fba5f23c9a0da64a2 Former-commit-id: c2f06e6fa5c46fd71c14f7a24a17644873855fc8 [formerly cd9acd8f3b7207615d4c94cbca727c36e8d7bf24] Former-commit-id: e9bafe627ad08e8d749003ccdc89a7102c8a7d50 Former-commit-id: 78a36587924dd602ff6e162bb7e7db4e324aaec7 Former-commit-id: 8c626144ba89409472f214b95a075e6917235600 Former-commit-id: 2a7f31432021e3ac207f813730311db6a30ccdcc Former-commit-id: 4feb9a4d4a6fb4accd617a1c90ce7cdb81fd591c
32 lines
809 B
JavaScript
32 lines
809 B
JavaScript
import Vue from 'vue'
|
|
import VueI18n from 'vue-i18n'
|
|
import util from '@/libs/util'
|
|
|
|
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
|
|
}
|
|
|
|
const messages = loadLocaleMessages()
|
|
|
|
Vue.prototype.$languages = Object.keys(messages).map(langlage => ({
|
|
label: messages[langlage]._name,
|
|
value: langlage
|
|
}))
|
|
|
|
export default new VueI18n({
|
|
locale: util.cookies.get('lang') || process.env.VUE_APP_I18N_LOCALE,
|
|
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE,
|
|
messages
|
|
})
|