From 5dc0494bb73b665a8dbd20f5983ae4ca3527d259 Mon Sep 17 00:00:00 2001 From: Till JS Date: Mon, 27 Apr 2026 13:57:38 +0200 Subject: [PATCH] =?UTF-8?q?i18n(food):=20translate=20/food/[id]=20+page.sv?= =?UTF-8?q?elte=20via=20$=5F()=20=E2=80=94=20meal=20detail=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - with {description} interpolation, untitled fallback - Back link, "Mahlzeit nicht gefunden." empty-state - Lightbox aria-labels (vergrößern/schließen) - Nutrient grid labels (Kalorien/Protein/Kohlenhydrate/Fett) via food.nutrition.* + Ballaststoffe/Zucker via food.detail.fiber_with_value/sugar_with_value - Action buttons: Bearbeiten, "🔄 Erneut analysieren" + Analysiere…, Löschen + Sicher? + Abbrechen + delete-confirm Löschen - Edit form: Mahlzeittyp/Beschreibung labels, Nährwerte heading, 6 nutrient input labels, Abbrechen/Speichere…/Speichern - Foods section heading "Erkannte Bestandteile" - Date formatter `toLocaleString('de-DE', …)` → `toLocaleString(get(locale) ?? 'de', …)` - All 4 catch-block error fallbacks routed via $_() Baselines: hardcoded 1140 → 1130 (10 cleared); missing-keys baseline unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --- .../src/routes/(app)/food/[id]/+page.svelte | 98 ++++++++++++------- scripts/i18n-hardcoded-baseline.json | 1 - 2 files changed, 63 insertions(+), 36 deletions(-) diff --git a/apps/mana/apps/web/src/routes/(app)/food/[id]/+page.svelte b/apps/mana/apps/web/src/routes/(app)/food/[id]/+page.svelte index 84391e4fb..5a5f45c38 100644 --- a/apps/mana/apps/web/src/routes/(app)/food/[id]/+page.svelte +++ b/apps/mana/apps/web/src/routes/(app)/food/[id]/+page.svelte @@ -8,6 +8,9 @@ import type { MealType, MealWithNutrition, NutritionData } from '$lib/modules/food/types'; import { ArrowLeft, Trash } from '@mana/shared-icons'; import { RoutePage } from '$lib/components/shell'; + import { _ } from 'svelte-i18n'; + import { get } from 'svelte/store'; + import { locale } from 'svelte-i18n'; // Inline the live query so the closure captures page.params.id directly // (matches the plants DetailView pattern). @@ -58,7 +61,7 @@ async function saveEdit() { if (!meal) return; if (!editDescription.trim()) { - error = 'Beschreibung darf nicht leer sein'; + error = $_('food.detail.error_description_required'); return; } saving = true; @@ -83,7 +86,7 @@ editing = false; } catch (err) { console.error('meal update failed:', err); - error = 'Speichern fehlgeschlagen'; + error = $_('food.detail.error_save_failed'); } finally { saving = false; } @@ -111,7 +114,7 @@ }); } catch (err) { console.error('re-analyze failed:', err); - error = 'KI-Analyse fehlgeschlagen'; + error = $_('food.detail.error_analyze_failed'); } finally { reanalyzing = false; } @@ -124,13 +127,14 @@ goto('/food'); } catch (err) { console.error('delete failed:', err); - error = 'Löschen fehlgeschlagen'; + error = $_('food.detail.error_delete_failed'); confirmDelete = false; } } function formatDateTime(dateString: string): string { - return new Date(dateString).toLocaleString('de-DE', { + const lang = get(locale) ?? 'de'; + return new Date(dateString).toLocaleString(lang, { weekday: 'long', day: 'numeric', month: 'long', @@ -145,24 +149,30 @@ </script> <svelte:head> - <title>{meal?.description ?? 'Mahlzeit'} - Food - Mana + {$_('food.detail.page_title_html', { + values: { description: meal?.description ?? $_('food.detail.untitled_fallback') }, + })} - +
- Zurueck + {$_('food.detail.back')} {#if !meal}
-

Mahlzeit nicht gefunden.

+

+ {$_('food.detail.not_found')} +

{:else} {#if error} @@ -179,7 +189,7 @@ type="button" onclick={() => (lightboxOpen = true)} class="block w-full overflow-hidden rounded-xl border border-[hsl(var(--color-border))] bg-[hsl(var(--color-muted))] transition-opacity hover:opacity-95" - aria-label="Bild vergrößern" + aria-label={$_('food.detail.lightbox_open_aria')} > {meal.description} @@ -220,7 +230,9 @@ class="h-2 w-2 rounded-full" style="background-color: {NUTRIENT_INFO.calories.color}" >
- Kalorien + {$_('food.nutrition.calories')}

{meal.nutrition.calories} @@ -235,7 +247,9 @@ class="h-2 w-2 rounded-full" style="background-color: {NUTRIENT_INFO.protein.color}" > - Protein + {$_('food.nutrition.protein')}

{meal.nutrition.protein} Kohlenhydrate{$_('food.nutrition.carbs')}

@@ -265,7 +279,9 @@ class="h-2 w-2 rounded-full" style="background-color: {NUTRIENT_INFO.fat.color}" > - Fett + {$_('food.nutrition.fat')}

{meal.nutrition.fat} -

Ballaststoffe: {meal.nutrition.fiber}g
-
Zucker: {meal.nutrition.sugar}g
+
+ {$_('food.detail.fiber_with_value', { + values: { n: meal.nutrition.fiber }, + })} +
+
+ {$_('food.detail.sugar_with_value', { + values: { n: meal.nutrition.sugar }, + })} +
{/if} @@ -288,7 +312,7 @@ onclick={startEdit} class="rounded-lg border border-[hsl(var(--color-border))] px-4 py-2 text-sm text-[hsl(var(--color-foreground))] hover:bg-[hsl(var(--color-muted))]" > - Bearbeiten + {$_('food.common.edit')} {#if meal.inputType === 'photo' && meal.photoUrl} {/if} {#if !confirmDelete} @@ -307,24 +333,26 @@ class="ml-auto inline-flex items-center gap-1 rounded-lg border border-[hsl(var(--color-border))] px-4 py-2 text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20" > - Löschen + {$_('food.common.delete')} {:else}
- Sicher? + {$_('food.detail.confirm_sure')}
{/if} @@ -334,7 +362,7 @@
- Mahlzeittyp + {$_('food.detail.label_meal_type')}
{#each mealTypes as type} @@ -357,7 +385,7 @@ for="edit-desc" class="mb-2 block text-sm font-medium text-[hsl(var(--color-foreground))]" > - Beschreibung + {$_('food.detail.label_description')}