Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
⚡ improvement(generator): all locale messages importing
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Mar 15, 2018
1 parent 2a91d36 commit c930bd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 12 additions & 2 deletions generator/templates/basic/src/i18n.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import messages from './locales'

Vue.use(VueI18n)

function loadLocaleMessages () {
const locales = require.context('./locales', true, /[a-z0-9]+\.json$/i)
const messages = {}
locales.keys().forEach(key => {
const locale = key.match(/([a-z0-9]+)\./i)[1]
messages[locale] = locales(key)
})
return messages
}

export default new VueI18n({
locale: 'en',
messages
fallbackLocale: 'en',
messages: loadLocaleMessages()
})
5 changes: 0 additions & 5 deletions generator/templates/basic/src/locales/index.js

This file was deleted.

0 comments on commit c930bd5

Please sign in to comment.