mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
Refactor datetimeFormats to dedicated locale files
This commit is contained in:
parent
b9982c07f8
commit
13507afebf
17 changed files with 83 additions and 22 deletions
|
@ -3,12 +3,8 @@ import VueI18n from "vue-i18n";
|
||||||
|
|
||||||
Vue.use(VueI18n);
|
Vue.use(VueI18n);
|
||||||
|
|
||||||
function loadLocaleMessages() {
|
|
||||||
const locales = require.context(
|
function parseLocaleFiles(locales) {
|
||||||
"./locales",
|
|
||||||
true,
|
|
||||||
/[A-Za-z0-9-_,\s]+\.json$/i
|
|
||||||
);
|
|
||||||
const messages = {};
|
const messages = {};
|
||||||
locales.keys().forEach(key => {
|
locales.keys().forEach(key => {
|
||||||
const matched = key.match(/([A-Za-z0-9-_]+)\./i);
|
const matched = key.match(/([A-Za-z0-9-_]+)\./i);
|
||||||
|
@ -20,21 +16,22 @@ function loadLocaleMessages() {
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateTimeFormats = {
|
function loadLocaleMessages() {
|
||||||
'en': {
|
const locales = require.context(
|
||||||
short: {
|
"./locales/messages",
|
||||||
month: 'short',
|
true,
|
||||||
day: 'numeric',
|
/[A-Za-z0-9-_,\s]+\.json$/i
|
||||||
weekday: 'long'
|
);
|
||||||
},
|
return parseLocaleFiles(locales);
|
||||||
},
|
}
|
||||||
'fr': {
|
|
||||||
short: {
|
function loadDateTimeFormats() {
|
||||||
month: 'short',
|
const locales = require.context(
|
||||||
day: 'numeric',
|
"./locales/dateTimeFormats",
|
||||||
weekday: 'long'
|
true,
|
||||||
}
|
/[A-Za-z0-9-_,\s]+\.json$/i
|
||||||
}
|
);
|
||||||
|
return parseLocaleFiles(locales);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,5 +39,5 @@ export default new VueI18n({
|
||||||
locale: "en",
|
locale: "en",
|
||||||
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || "en",
|
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || "en",
|
||||||
messages: loadLocaleMessages(),
|
messages: loadLocaleMessages(),
|
||||||
dateTimeFormats
|
dateTimeFormats: loadDateTimeFormats()
|
||||||
});
|
});
|
||||||
|
|
7
frontend/src/locales/dateTimeFormats/da.json
Normal file
7
frontend/src/locales/dateTimeFormats/da.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
7
frontend/src/locales/dateTimeFormats/de.json
Normal file
7
frontend/src/locales/dateTimeFormats/de.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
7
frontend/src/locales/dateTimeFormats/en.json
Normal file
7
frontend/src/locales/dateTimeFormats/en.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
7
frontend/src/locales/dateTimeFormats/fr.json
Normal file
7
frontend/src/locales/dateTimeFormats/fr.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
7
frontend/src/locales/dateTimeFormats/pl.json
Normal file
7
frontend/src/locales/dateTimeFormats/pl.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
7
frontend/src/locales/dateTimeFormats/sv.json
Normal file
7
frontend/src/locales/dateTimeFormats/sv.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
7
frontend/src/locales/dateTimeFormats/zh-CN.json
Normal file
7
frontend/src/locales/dateTimeFormats/zh-CN.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
7
frontend/src/locales/dateTimeFormats/zh-TW.json
Normal file
7
frontend/src/locales/dateTimeFormats/zh-TW.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,12 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
|
"dateTimeFormats": {
|
||||||
|
"short": {
|
||||||
|
"month": "short",
|
||||||
|
"day": "numeric",
|
||||||
|
"weekday": "long"
|
||||||
|
}
|
||||||
|
},
|
||||||
"404": {
|
"404": {
|
||||||
"page-not-found": "404 Page Not Found",
|
"page-not-found": "404 Page Not Found",
|
||||||
"take-me-home": "Take me Home"
|
"take-me-home": "Take me Home"
|
Loading…
Add table
Add a link
Reference in a new issue