fix partial field translation overwriting entire translation
All checks were successful
CI / update (push) Successful in 8s
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:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user