mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
Localized meal date (#182)
* first step towards localized meal date * Refactor datetimeFormats to dedicated locale files * localized date in 'Dinner this week'
This commit is contained in:
parent
2717613443
commit
68b6a3a256
20 changed files with 91 additions and 11 deletions
|
@ -17,7 +17,7 @@
|
||||||
:src="getImage(meal.slug)"
|
:src="getImage(meal.slug)"
|
||||||
@click="openSearch(index)"
|
@click="openSearch(index)"
|
||||||
></v-img>
|
></v-img>
|
||||||
<v-card-title class="my-n3 mb-n6">{{ meal.dateText }}</v-card-title>
|
<v-card-title class="my-n3 mb-n6">{{ $d( new Date(meal.date), 'short' ) }}</v-card-title>
|
||||||
<v-card-subtitle> {{ meal.name }}</v-card-subtitle>
|
<v-card-subtitle> {{ meal.name }}</v-card-subtitle>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-hover>
|
</v-hover>
|
||||||
|
|
|
@ -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,8 +16,28 @@ function loadLocaleMessages() {
|
||||||
return messages;
|
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({
|
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: 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"
|
|
@ -25,8 +25,8 @@
|
||||||
>
|
>
|
||||||
<v-card class="mt-1">
|
<v-card class="mt-1">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
{{ formatDate(mealplan.startDate) }} -
|
{{ $d( new Date(mealplan.startDate), 'short' ) }} -
|
||||||
{{ formatDate(mealplan.endDate) }}
|
{{ $d( new Date(mealplan.endDate), 'short' ) }}
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-list nav>
|
<v-list nav>
|
||||||
<v-list-item-group color="primary">
|
<v-list-item-group color="primary">
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
</v-list-item-avatar>
|
</v-list-item-avatar>
|
||||||
<v-list-item-content>
|
<v-list-item-content>
|
||||||
<v-list-item-title v-text="meal.name"></v-list-item-title>
|
<v-list-item-title v-text="meal.name"></v-list-item-title>
|
||||||
<v-list-item-subtitle v-text="meal.dateText">
|
<v-list-item-subtitle v-text="$d( new Date(meal.date), 'short' )" >
|
||||||
</v-list-item-subtitle>
|
</v-list-item-subtitle>
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<v-card-title class="justify-center">
|
<v-card-title class="justify-center">
|
||||||
{{ meal.name }}
|
{{ meal.name }}
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-subtitle> {{ meal.dateText }}</v-card-subtitle>
|
<v-card-subtitle> {{ $d(new Date(meal.date), 'short' ) }}</v-card-subtitle>
|
||||||
|
|
||||||
<v-card-text> {{ meal.description }} </v-card-text>
|
<v-card-text> {{ meal.description }} </v-card-text>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue