From fb68df3ba964f92fc40753d0b976c1ed6d6d154f Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 13 Sep 2026 12:54:00 +0200 Subject: [PATCH] feat(import): apply translation to successful bulk items The interactive batch ignored the client's Translate option, so translated names never landed in the language files during a bulk run. Patch each successful item through patchLocalizedFurniDataEntries (mutex-guarded, best-effort) when translation is requested, surfacing failures as item warnings instead of failing the import. --- src/app/api/admin/import/furni/batch/route.ts | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/app/api/admin/import/furni/batch/route.ts b/src/app/api/admin/import/furni/batch/route.ts index e7c719bb..9a603fc6 100644 --- a/src/app/api/admin/import/furni/batch/route.ts +++ b/src/app/api/admin/import/furni/batch/route.ts @@ -12,7 +12,10 @@ import { reconcileFurniDataWithItemsBase, verifyAndFixSpriteIds, } from "@/lib/services/furni-data"; -import { buildLocalizedFurniDataFiles } from "@/lib/services/furni-data-i18n"; +import { + buildLocalizedFurniDataFiles, + patchLocalizedFurniDataEntries, +} from "@/lib/services/furni-data-i18n"; import { ensureDirectories, ensureFurniOwnership, @@ -247,15 +250,46 @@ export const POST = withAdmin( if (result.ok) { succeeded++; - if (result.warnings.length > 0) withWarnings++; + const warnings = [...result.warnings]; if (result.furniDataEntry) furniDataEntries.push(result.furniDataEntry); + // Translation is best-effort, same as the queue worker: + // a failure warns but never fails the import. + if (body.translate === true) { + try { + send({ + type: "item_progress", + classname: item.classname, + status: "translating", + index, + }); + await patchLocalizedFurniDataEntries( + [ + { + classname: item.classname, + name: item.name, + description: item.description, + }, + ], + true, + Array.isArray(body.langs) && body.langs.length > 0 + ? body.langs + : undefined, + ); + } catch { + warnings.push( + "Translation failed; furniture imported successfully", + ); + } + } + + if (warnings.length > 0) withWarnings++; + if (entry) { entry.state = "done"; entry.itemId = result.itemId; - entry.warnings = - result.warnings.length > 0 ? result.warnings : undefined; + entry.warnings = warnings.length > 0 ? warnings : undefined; checkpoint(); } @@ -265,8 +299,7 @@ export const POST = withAdmin( status: "done", index, itemId: result.itemId, - warnings: - result.warnings.length > 0 ? result.warnings : undefined, + warnings: warnings.length > 0 ? warnings : undefined, }); logAudit({