From d540b82e854a11daceb46816e86a4337b8aa8830 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 1 May 2026 13:22:59 +0200 Subject: [PATCH] i18n(recipes): bootstrap namespace + migrate layout, NutritionSummary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two-locale recipes dictionary lands at src/lib/i18n/recipes/{de,en}.ts with the same satisfies-based completeness enforcement as the other namespaces. recipesI18n.ts is the slim shim — exports m, RecipesLang, RecipesKey, plus langFromRecipeSlug / recipeSlugFromLang helpers for the rezepte ↔ recipes URL slug mapping. [recipeLang]/+layout.svelte's nav-label ternary chain collapses into t.foo lookups. NutritionSummary.svelte is the heavy hitter — 33 inline isEnglish ternaries become a single dictionary load. Most amino-acid names use a German-stem-plus-optional-e pattern in the old code (`Lysin{isEnglish ? 'e' : ''}`) that's now just t.lysine in the template; less clever, much more obviously translatable. --- .../recipes/NutritionSummary.svelte | 70 ++++++++++--------- src/lib/i18n/recipes/de.ts | 46 ++++++++++++ src/lib/i18n/recipes/en.ts | 46 ++++++++++++ src/lib/js/recipesI18n.ts | 39 +++++++++++ .../[recipeLang=recipeLang]/+layout.svelte | 18 +++-- 5 files changed, 179 insertions(+), 40 deletions(-) create mode 100644 src/lib/i18n/recipes/de.ts create mode 100644 src/lib/i18n/recipes/en.ts create mode 100644 src/lib/js/recipesI18n.ts diff --git a/src/lib/components/recipes/NutritionSummary.svelte b/src/lib/components/recipes/NutritionSummary.svelte index bd1e85ad..1b7a0aba 100644 --- a/src/lib/components/recipes/NutritionSummary.svelte +++ b/src/lib/components/recipes/NutritionSummary.svelte @@ -1,8 +1,12 @@