From d7005958cf5dec9898776399fa6075feb193d9b9 Mon Sep 17 00:00:00 2001 From: Florian Dupret <34862846+sephrat@users.noreply.github.com> Date: Thu, 22 Apr 2021 11:11:35 +0200 Subject: [PATCH] Localize more dates and texts --- .../src/components/MealPlan/MealPlanNew.vue | 7 +-- .../MealPlan/ShoppingListDialog.vue | 4 +- .../src/locales/dateTimeFormats/en-US.json | 6 ++ frontend/src/locales/messages/en-US.json | 4 +- .../Admin/Backup/AvailableBackupCard.vue | 7 +-- .../src/pages/Admin/Backup/BackupCard.vue | 7 +-- .../pages/Admin/Migration/MigrationCard.vue | 7 +-- frontend/src/pages/MealPlan/Planner.vue | 4 -- frontend/src/utils/index.js | 55 ------------------- 9 files changed, 15 insertions(+), 86 deletions(-) diff --git a/frontend/src/components/MealPlan/MealPlanNew.vue b/frontend/src/components/MealPlan/MealPlanNew.vue index dd56a0ec7..39f706ab8 100644 --- a/frontend/src/components/MealPlan/MealPlanNew.vue +++ b/frontend/src/components/MealPlan/MealPlanNew.vue @@ -3,7 +3,7 @@ {{ $t("meal-plan.create-a-new-meal-plan") }} - mdi-calendar-minus Quick Week + mdi-calendar-minus {{$t('meal-plan.quick-week')}} @@ -110,7 +110,6 @@ export default { this.meals.push({ slug: "empty", date: this.getDate(i), - dateText: this.getDayText(i), }); } }, @@ -193,10 +192,6 @@ export default { ); return dateText; }, - getDayText(index) { - const dateObj = this.processTime(index); - return utils.getDateAsText(dateObj); - }, getDate(index) { const dateObj = this.processTime(index); return utils.getDateAsPythonDate(dateObj); diff --git a/frontend/src/components/MealPlan/ShoppingListDialog.vue b/frontend/src/components/MealPlan/ShoppingListDialog.vue index b92800d64..8bd2da175 100644 --- a/frontend/src/components/MealPlan/ShoppingListDialog.vue +++ b/frontend/src/components/MealPlan/ShoppingListDialog.vue @@ -3,10 +3,10 @@ - Shopping List + {{$t('meal-plan.shopping-list')}} - Group (Beta) + {{$t('meal-plan.group')}} diff --git a/frontend/src/locales/dateTimeFormats/en-US.json b/frontend/src/locales/dateTimeFormats/en-US.json index 65941802f..30688d4e0 100644 --- a/frontend/src/locales/dateTimeFormats/en-US.json +++ b/frontend/src/locales/dateTimeFormats/en-US.json @@ -3,5 +3,11 @@ "month": "short", "day": "numeric", "weekday": "long" + }, + "medium": { + "month": "long", + "day": "numeric", + "weekday": "long", + "year": "numeric" } } \ No newline at end of file diff --git a/frontend/src/locales/messages/en-US.json b/frontend/src/locales/messages/en-US.json index 9a63052c5..a212e6214 100644 --- a/frontend/src/locales/messages/en-US.json +++ b/frontend/src/locales/messages/en-US.json @@ -122,7 +122,9 @@ "create-a-new-meal-plan": "Create a New Meal Plan", "start-date": "Start Date", "end-date": "End Date", - "only-recipes-with-these-categories-will-be-used-in-meal-plans": "Only recipes with these categories will be used in Meal Plans" + "only-recipes-with-these-categories-will-be-used-in-meal-plans": "Only recipes with these categories will be used in Meal Plans", + "quick-week": "Quick Week", + "group": "Group (Beta)" }, "recipe": { "description": "Description", diff --git a/frontend/src/pages/Admin/Backup/AvailableBackupCard.vue b/frontend/src/pages/Admin/Backup/AvailableBackupCard.vue index 499d2c4cd..b9a9b4366 100644 --- a/frontend/src/pages/Admin/Backup/AvailableBackupCard.vue +++ b/frontend/src/pages/Admin/Backup/AvailableBackupCard.vue @@ -27,7 +27,7 @@
{{ backup.name }}
-
{{ readableTime(backup.date) }}
+
{{ $d(new Date(backup.date), "medium") }}
@@ -40,7 +40,6 @@ diff --git a/frontend/src/pages/MealPlan/Planner.vue b/frontend/src/pages/MealPlan/Planner.vue index 2d472216d..72add28bd 100644 --- a/frontend/src/pages/MealPlan/Planner.vue +++ b/frontend/src/pages/MealPlan/Planner.vue @@ -112,10 +112,6 @@ export default { generateKey(name, index) { return utils.generateUniqueKey(name, index); }, - formatDate(timestamp) { - let dateObject = new Date(timestamp); - return utils.getDateAsTextAlt(dateObject); - }, getImage(image) { return api.recipes.recipeTinyImage(image); }, diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index e292d9062..d1f5afe7a 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -9,45 +9,6 @@ const notifyHelpers = { info: "notify-info-color", }; -const days = [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", -]; -const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", -]; - -const monthsShort = [ - "Jan", - "Feb", - "March", - "April", - "May", - "June", - "July", - "Aug", - "Sept", - "Oct", - "Nov", - "Dec", -]; - export default { getImageURL(image) { return `/api/recipes/${image}/image?image_type=small`; @@ -56,22 +17,6 @@ export default { const uniqueKey = `${item}-${index}`; return uniqueKey; }, - getDateAsText(dateObject) { - const dow = days[dateObject.getUTCDay()]; - const month = months[dateObject.getUTCMonth()]; - const day = dateObject.getUTCDate(); - // const year = dateObject.getFullYear(); - - return `${dow}, ${month} ${day}`; - }, - getDateAsTextAlt(dateObject) { - const dow = days[dateObject.getUTCDay()]; - const month = monthsShort[dateObject.getUTCMonth()]; - const day = dateObject.getUTCDate(); - // const year = dateObject.getFullYear(); - - return `${dow}, ${month} ${day}`; - }, getDateAsPythonDate(dateObject) { const month = dateObject.getUTCMonth() + 1; const day = dateObject.getUTCDate();