From 2fa9a8bdeb41b15ce3e81b92fee51ce6ed9fe695 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Sat, 27 Dec 2025 14:00:18 +0100 Subject: [PATCH] fix partial field translation overwriting entire translation When re-translating only changed fields (e.g., just ingredients), the partial result was replacing the entire English translation, causing name, short_name, description, and category to be lost. Now merge partial translations with existing translation data to preserve unchanged fields while updating only the modified ones. --- src/lib/components/TranslationApproval.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/components/TranslationApproval.svelte b/src/lib/components/TranslationApproval.svelte index 0fb8440..b6cbd35 100644 --- a/src/lib/components/TranslationApproval.svelte +++ b/src/lib/components/TranslationApproval.svelte @@ -44,7 +44,15 @@ } const result = await response.json(); - editableEnglish = result.translatedRecipe; + + // If translating only specific fields, merge with existing translation + // Otherwise use the full translation result + if (isEditMode && changedFields.length > 0 && englishData) { + editableEnglish = { ...englishData, ...result.translatedRecipe }; + } else { + editableEnglish = result.translatedRecipe; + } + translationState = 'preview'; // Notify parent component