blob: 09b3f4ca9467d73664507fec895743ded046acc6 [file] [log] [blame]
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({
// default language is English
locale: 'en',
// locale messages with a message key that doesn't exist will fallback to English
fallbackLocale: 'en',
messages: loadLocaleMessages()
});