mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-08 21:16:28 -05:00
* automated docs update * recipe rating component * recipe partial updates - closes #25 * use Vue.delete to update store * format * arrow functions * fix tests * format * initial context menu * localize * add confirmation dialog * context menu * fix bare exception * update line length * format all file with prettier * update changelog * download as json * update python dependencies * update javascript dependencies Co-authored-by: hay-kot <hay-kot@pm.me>
34 lines
903 B
JavaScript
34 lines
903 B
JavaScript
import Vue from "vue";
|
|
import VueI18n from "vue-i18n";
|
|
|
|
Vue.use(VueI18n);
|
|
|
|
function parseLocaleFiles(locales) {
|
|
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;
|
|
}
|
|
|
|
function loadLocaleMessages() {
|
|
const locales = require.context("./locales/messages", true, /[A-Za-z0-9-_,\s]+\.json$/i);
|
|
return parseLocaleFiles(locales);
|
|
}
|
|
|
|
function loadDateTimeFormats() {
|
|
const locales = require.context("./locales/dateTimeFormats", true, /[A-Za-z0-9-_,\s]+\.json$/i);
|
|
return parseLocaleFiles(locales);
|
|
}
|
|
|
|
export default new VueI18n({
|
|
locale: "en-US",
|
|
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || "en-US",
|
|
messages: loadLocaleMessages(),
|
|
dateTimeFormats: loadDateTimeFormats(),
|
|
});
|