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.
32 lines
699 B
32 lines
699 B
import { createI18n } from 'vue-i18n';
|
|
|
|
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;
|
|
}
|
|
|
|
let locale = document.querySelector('html').lang;
|
|
if (!locale) {
|
|
locale = 'en'
|
|
}
|
|
|
|
export default createI18n({
|
|
legacy: false,
|
|
locale: locale,
|
|
fallbackLocale: 'en',
|
|
messages: loadLocaleMessages()
|
|
}); |