From 4e86b1b724e914961915c4e34c7780d071023174 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Aug 2026 00:06:33 +0000 Subject: [PATCH] =?UTF-8?q?i18n(recept):=20steg=20+=20t=C3=A4cknings-etike?= =?UTF-8?q?tter=20spanska,=20=C3=B6versatta=20saknade-namn,=20cache-nyckel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cooking-skärmen renderade instructionSv (alltid svenska) -> nu instruction ?? instructionSv - recept-skärmens täckningskort hårdkodade svenska (Du har X% hemma, Saknar N, Du saknar, Lägg till i inköpslistan, Tillagt) -> t()-nycklar recipe.coverage.* - coverage.missing fick översatt displayName i API:t (annars svenska ingrediensnamn) - 7 nya recipe.coverage.*-nycklar i alla 12 språk - persister-cache-nyckel -> -v2 (slänger gammal helsvensk cache en gang) Co-Authored-By: Claude --- apps/api/src/routes/recipes.ts | 8 +++++++- apps/mobile/src/app/_layout.tsx | 2 +- apps/mobile/src/app/cooking/[id].tsx | 3 ++- apps/mobile/src/app/recipe/[id].tsx | 19 ++++++++++++------- apps/mobile/src/locales/da/common.json | 7 +++++++ apps/mobile/src/locales/de/common.json | 7 +++++++ apps/mobile/src/locales/en/common.json | 7 +++++++ apps/mobile/src/locales/es/common.json | 7 +++++++ apps/mobile/src/locales/fi/common.json | 7 +++++++ apps/mobile/src/locales/fr/common.json | 7 +++++++ apps/mobile/src/locales/it/common.json | 7 +++++++ apps/mobile/src/locales/nb/common.json | 7 +++++++ apps/mobile/src/locales/nl/common.json | 7 +++++++ apps/mobile/src/locales/pl/common.json | 7 +++++++ apps/mobile/src/locales/pt/common.json | 7 +++++++ apps/mobile/src/locales/sv/common.json | 7 +++++++ 16 files changed, 106 insertions(+), 10 deletions(-) diff --git a/apps/api/src/routes/recipes.ts b/apps/api/src/routes/recipes.ts index 96a26d5..9ae07fb 100644 --- a/apps/api/src/routes/recipes.ts +++ b/apps/api/src/routes/recipes.ts @@ -261,7 +261,13 @@ export async function recipeRoutes(app: FastifyInstance) { }), safety, variants, - coverage, + coverage: coverage && { + ...coverage, + missing: coverage.missing.map((m) => ({ + ...m, + displayName: ingredientNames.get(m.canonicalIngredientId) ?? m.displayNameSv, + })), + }, myRating: myRating ?? null, isFavorite: Boolean(favorite), }; diff --git a/apps/mobile/src/app/_layout.tsx b/apps/mobile/src/app/_layout.tsx index 131c45b..49b52e6 100644 --- a/apps/mobile/src/app/_layout.tsx +++ b/apps/mobile/src/app/_layout.tsx @@ -29,7 +29,7 @@ const queryClient = new QueryClient({ const persister = createAsyncStoragePersister({ storage: AsyncStorage, - key: `${BRAND.slug}-query-cache`, + key: `${BRAND.slug}-query-cache-v2`, }); export default function RootLayout() { diff --git a/apps/mobile/src/app/cooking/[id].tsx b/apps/mobile/src/app/cooking/[id].tsx index 4c60ba5..6fb60c6 100644 --- a/apps/mobile/src/app/cooking/[id].tsx +++ b/apps/mobile/src/app/cooking/[id].tsx @@ -34,6 +34,7 @@ interface RecipeForCooking { id: string; stepNumber: number; instructionSv: string; + instruction?: string; timerSeconds: number | null; temperatureC: number | null; tip: string | null; @@ -246,7 +247,7 @@ export default function CookingScreen() { {t("cooking.step", { current: stepIndex + 1, total: recipe.steps.length })} - {step?.instructionSv} + {step?.instruction ?? step?.instructionSv} {step?.temperatureC ? ` (${step.temperatureC} °C)` : ""} {step?.tip && 💡 {step.tip}} diff --git a/apps/mobile/src/app/recipe/[id].tsx b/apps/mobile/src/app/recipe/[id].tsx index f144360..3b96825 100644 --- a/apps/mobile/src/app/recipe/[id].tsx +++ b/apps/mobile/src/app/recipe/[id].tsx @@ -61,6 +61,7 @@ interface RecipeDetail { missing: Array<{ canonicalIngredientId: string; displayNameSv: string; + displayName?: string; quantity: number; unit: string; }>; @@ -181,8 +182,8 @@ export default function RecipeScreen() { onSuccess: (count) => { void queryClient.invalidateQueries({ queryKey: ["shopping-lists"] }); Alert.alert( - "Tillagt i inköpslistan", - `${count} ${count === 1 ? "vara" : "varor"} lades till.`, + t("recipe.coverage.added"), + t("recipe.coverage.addedBody", { count }), ); }, onError: (err) => { @@ -263,21 +264,25 @@ export default function RecipeScreen() { {recipe.coverage && ( - Du har {recipe.coverage.percent}% hemma + {t("recipe.coverage.have", { percent: recipe.coverage.percent })} {recipe.coverage.missing.length > 0 && ( - + )} {recipe.coverage.missing.length === 0 ? ( - Du har allt som behövs. + {t("recipe.coverage.haveAll")} ) : ( <> - Du saknar: {recipe.coverage.missing.map((m) => m.displayNameSv).join(", ")} + {t("recipe.coverage.youAreMissing", { + names: recipe.coverage.missing + .map((m) => m.displayName ?? m.displayNameSv) + .join(", "), + })}