feat: per-import translation toggle and language picker in studio
Furni imports can now choose whether to translate (per import) and which languages to build, instead of always rebuilding all 13 FurnitureData_<lang> files. The studio header also has a global switch that persists the furnidata_translate_enabled setting, seeding the per-import default.
This commit is contained in:
1 parent
d6af754211
commit
6dced0fb54
5 files changed
+223
-10
No files matched your search
@@ -527,11 +527,24 @@ export const POST = withAdmin(
|
||||
const { catalogNameFixed, haveOfferFixed, costCreditsFixed } =
|
||||
await fixDatabaseConsistencyAfterImport();
|
||||
|
||||
// Rebuild all localized furnidata files (best effort)
|
||||
// Rebuild localized furnidata files (best effort). `translate: false`
|
||||
// skips entirely; `translate: true` forces a build even when the global
|
||||
// setting is off; undefined falls back to the global setting. An optional
|
||||
// `langs` array restricts which languages are rebuilt.
|
||||
let languages: Awaited<ReturnType<typeof buildLocalizedFurniDataFiles>> =
|
||||
[];
|
||||
try {
|
||||
languages = await buildLocalizedFurniDataFiles();
|
||||
if (body.translate !== false) {
|
||||
const langs = Array.isArray(body.langs)
|
||||
? (body.langs as unknown[]).filter(
|
||||
(l): l is string => typeof l === "string",
|
||||
)
|
||||
: undefined;
|
||||
languages = await buildLocalizedFurniDataFiles(
|
||||
body.translate === true,
|
||||
langs,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
"[import-furni] Localized furnidata build failed:",
|
||||
@@ -638,14 +651,24 @@ export const POST = withAdmin(
|
||||
// Verify + fix interaction_modes_count (single consolidated pass)
|
||||
const verification = await verifyAndFixInteractionModesCount();
|
||||
|
||||
// Patch localized furnidata files for this single furni (best effort)
|
||||
// Patch localized furnidata files for this single furni (best effort).
|
||||
// Same `translate` / `langs` contract as the batch path above.
|
||||
let languagesPatch: Awaited<
|
||||
ReturnType<typeof patchLocalizedFurniDataEntries>
|
||||
> = [];
|
||||
try {
|
||||
languagesPatch = await patchLocalizedFurniDataEntries([
|
||||
{ classname, name, description: description ?? "" },
|
||||
]);
|
||||
if (body.translate !== false) {
|
||||
const langs = Array.isArray(body.langs)
|
||||
? (body.langs as unknown[]).filter(
|
||||
(l): l is string => typeof l === "string",
|
||||
)
|
||||
: undefined;
|
||||
languagesPatch = await patchLocalizedFurniDataEntries(
|
||||
[{ classname, name, description: description ?? "" }],
|
||||
body.translate === true,
|
||||
langs,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
"[import-furni] Localized patch failed:",
|
||||
|
||||
Reference in new issue
Block a user