Persist recipe English name translation to database
Some checks failed
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Failing after 1m7s
PR Preview / test (pull_request) Has been skipped
PR Preview / teardown-preview (pull_request) Successful in 14s
PR Preview / deploy-preview (pull_request) Has been skipped
Some checks failed
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Failing after 1m7s
PR Preview / test (pull_request) Has been skipped
PR Preview / teardown-preview (pull_request) Successful in 14s
PR Preview / deploy-preview (pull_request) Has been skipped
- Add en_name column to recipes table (migration in database.py) - Include en_name in recipe API responses and RecipeUpdate model - Save en_name when admin/senior_editor applies translation - Load en_name on overlay open, so translation persists across sessions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -518,9 +518,20 @@ function copyText() {
|
||||
})
|
||||
}
|
||||
|
||||
function applyTranslation() {
|
||||
// translations stored in customOilNameEn / customRecipeNameEn
|
||||
async function applyTranslation() {
|
||||
showTranslationEditor.value = false
|
||||
// Persist en_name to backend
|
||||
if (recipe.value._id && customRecipeNameEn.value) {
|
||||
try {
|
||||
await api.put(`/api/recipes/${recipe.value._id}`, {
|
||||
en_name: customRecipeNameEn.value,
|
||||
version: recipe.value._version,
|
||||
})
|
||||
ui.showToast('翻译已保存')
|
||||
} catch (e) {
|
||||
ui.showToast('翻译保存失败')
|
||||
}
|
||||
}
|
||||
cardImageUrl.value = null
|
||||
nextTick(() => generateCardImage())
|
||||
}
|
||||
@@ -535,7 +546,7 @@ function getCardOilName(name) {
|
||||
|
||||
function getCardRecipeName() {
|
||||
if (cardLang.value === 'en') {
|
||||
return customRecipeNameEn.value || recipeNameEn(recipe.value.name)
|
||||
return customRecipeNameEn.value || recipe.value.en_name || recipeNameEn(recipe.value.name)
|
||||
}
|
||||
return recipe.value.name
|
||||
}
|
||||
@@ -640,7 +651,7 @@ onMounted(() => {
|
||||
editTags.value = [...(r.tags || [])]
|
||||
editIngredients.value = (r.ingredients || []).map(i => ({ oil: i.oil, drops: i.drops }))
|
||||
// Init translation defaults
|
||||
customRecipeNameEn.value = recipeNameEn(r.name)
|
||||
customRecipeNameEn.value = r.en_name || recipeNameEn(r.name)
|
||||
const enMap = {}
|
||||
;(r.ingredients || []).forEach(ing => {
|
||||
enMap[ing.oil] = oilEn(ing.oil) || ing.oil
|
||||
|
||||
@@ -16,6 +16,7 @@ export const useRecipesStore = defineStore('recipes', () => {
|
||||
_owner_name: r._owner_name ?? r.owner_name ?? '',
|
||||
_version: r._version ?? r.version ?? 1,
|
||||
name: r.name,
|
||||
en_name: r.en_name ?? '',
|
||||
note: r.note ?? '',
|
||||
tags: r.tags ?? [],
|
||||
ingredients: (r.ingredients ?? []).map((ing) => ({
|
||||
|
||||
Reference in New Issue
Block a user