fix partial field translation overwriting entire translation
All checks were successful
CI / update (push) Successful in 8s

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.
This commit is contained in:
2025-12-27 14:00:18 +01:00
parent 4e2a7ff624
commit 2fa9a8bdeb

View File

@@ -44,7 +44,15 @@
} }
const result = await response.json(); const result = await response.json();
// 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; editableEnglish = result.translatedRecipe;
}
translationState = 'preview'; translationState = 'preview';
// Notify parent component // Notify parent component