✨ vue add i18n
Former-commit-id: 93a57ab73023e37e7bd418f4221db12507653d74 [formerly 93a57ab73023e37e7bd418f4221db12507653d74 [formerly 93a57ab73023e37e7bd418f4221db12507653d74 [formerly 93a57ab73023e37e7bd418f4221db12507653d74 [formerly 331c42f3cf9c23bf114ea692b3aa23662d0963a5 [formerly a5f9f2449758fcc55395ccba72fb785b1764b593]]]]] Former-commit-id: 2084d2f5552ba9ed91ce295cf7bc04e4d2a64e49 Former-commit-id: eb82e859e47e2ec91f48023c705189e538b986e8 Former-commit-id: 4f1713142447f154592c4b74fb5e167df4287be1 [formerly 6daa81e0511c54daab83f96ff69c37b0cd55cc55] Former-commit-id: 90771d09b3356812c438fa9cb8fa713c7fe86762 Former-commit-id: 58b881a85f8baab6e6ef578575953de17bff0d40 Former-commit-id: aef4bbe6556d4bc4b6eb561c28148dd8b4395cbf Former-commit-id: b12df0763e624fb55c9832ce4c7ec93ec881b19b Former-commit-id: 06c2000def6d103aff231bd7a53a02d9ace87ca2
This commit is contained in:
23
src/i18n.js
Normal file
23
src/i18n.js
Normal file
@@ -0,0 +1,23 @@
|
||||
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()
|
||||
})
|
||||
Reference in New Issue
Block a user