fix(catalog): sync localized FurniData files when translating items via admin UI
CI / check (push) Successful in 53s
CI / deploy (push) Successful in 1m34s

translateCatalogItems previously only patched the master FurnitureData.json
via patchFurniEntryNames but never updated the per-language files
(FurnitureData_nl.json, etc.). Custom/imported furniture translated through
the catalog Translate tab was therefore invisible in localized builds.

After patching the master file, the action now also calls
patchLocalizedFurniDataEntries so LibreTranslate translates the English
names into all 13 supported languages.
This commit is contained in:
openhands committed 2026-09-09 19:08:39 +02:00
1 parent b5ea8f1c0e
commit 1daada076c
1 file changed
+22
+22
View File
@@ -292,6 +292,9 @@ export async function translateCatalogItems(input: {
"@/lib/services/catalog-items-loader" "@/lib/services/catalog-items-loader"
); );
const { patchFurniEntryNames } = await import("@/lib/services/furni-data"); const { patchFurniEntryNames } = await import("@/lib/services/furni-data");
const { patchLocalizedFurniDataEntries } = await import(
"@/lib/services/furni-data-i18n"
);
let namesUpdated = 0; let namesUpdated = 0;
let descriptionsUpdated = 0; let descriptionsUpdated = 0;
@@ -303,6 +306,11 @@ export async function translateCatalogItems(input: {
spriteId?: number; spriteId?: number;
createIfMissing?: boolean; createIfMissing?: boolean;
}> = []; }> = [];
const localizedEntries: Array<{
classname: string;
name?: string;
description?: string;
}> = [];
for (const item of items) { for (const item of items) {
const [base] = await db const [base] = await db
@@ -356,6 +364,7 @@ export async function translateCatalogItems(input: {
if (nextDesc !== "" || nameChanged) { if (nextDesc !== "" || nameChanged) {
descriptionsUpdated += nextDesc !== "" ? 1 : 0; descriptionsUpdated += nextDesc !== "" ? 1 : 0;
const englishName = base.publicName?.trim() || base.itemName || "";
furniPatches.push({ furniPatches.push({
classname: base.itemName, classname: base.itemName,
itemType: base.type || "s", itemType: base.type || "s",
@@ -364,6 +373,11 @@ export async function translateCatalogItems(input: {
spriteId: base.spriteId, spriteId: base.spriteId,
createIfMissing: true, createIfMissing: true,
}); });
localizedEntries.push({
classname: base.itemName,
name: englishName,
description: nextDesc || undefined,
});
} }
} }
@@ -375,6 +389,14 @@ export async function translateCatalogItems(input: {
invalidateFurniDataCache(); invalidateFurniDataCache();
} }
if (localizedEntries.length > 0) {
try {
await patchLocalizedFurniDataEntries(localizedEntries, true);
} catch {
// Best-effort: localized files update is non-critical
}
}
await sendCatalogUpdate(); await sendCatalogUpdate();
await logAudit({ await logAudit({
userId: staff.id, userId: staff.id,