Send the remaining interface text through the catalog and audit it

Phase 4f.

- scripts/i18nAudit.mjs runs in pnpm check. It fails for a key that the
  catalog does not have, a catalog key that the code does not use, and
  a row without all four languages.
- message() marks a key that a variable carries to the translation call
  later: table formats, formula errors, and browser status messages.
- 53 new rows with French, Japanese, and Simplified Chinese text for the
  status and error messages of the workbench, the tree, Settings, theme
  import, images, the built-in browser, and code blocks. The backlinks
  toggle now translates too.
- 13 unused rows are gone.
- Errors of the plugin API stay in English. docs/development.md has the
  rule in "Interface text".

pnpm check, pnpm test (350 of 350), and the full smoke suite pass,
except two tests that failed one time under load and passed on retry
and 3 of 3 times alone.
This commit is contained in:
Knotty Wyvern
2026-10-28 12:00:24 -07:00
parent 3e6bc5f088
commit e9c59f28de
28 changed files with 249 additions and 171 deletions
+15 -15
View File
@@ -354,7 +354,7 @@
expanded = folders;
}
async function copyText(text: string, label: string) {
async function copyText(text: string, done: string) {
try {
await navigator.clipboard.writeText(text);
} catch {
@@ -365,7 +365,7 @@
document.execCommand("copy");
area.remove();
}
onStatus?.(`Copied ${label}`);
onStatus?.(done);
}
async function persistMarks(change: (current: Marks) => Marks) {
@@ -416,7 +416,7 @@
await load(parentRel(from));
selectOnly(plan.to);
await focusTreePath(plan.to);
onStatus?.(`Renamed to ${plan.to}`);
onStatus?.($t("Renamed to {path}", { path: plan.to }));
} catch (err) {
error = err instanceof Error ? err.message : String(err);
} finally { moving = false; }
@@ -512,7 +512,7 @@
}
await load(parent);
if (workspaceRoot !== operationRoot) return;
onStatus?.(`Created ${rel}`);
onStatus?.($t("Created {path}", { path: rel }));
if (kind === "folder") {
startRename({ name: finalName, rel_path: rel, kind: "folder" });
} else {
@@ -554,7 +554,7 @@
const paths = new Map(entries.map(entry => [entry.rel_path, entry.rel_path]));
moving = true;
const result = await runTreeActions(place === "after" ? [...entries].reverse() : entries, async entry => {
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
if (workspaceRoot !== operationRoot) throw new Error($t("The workspace changed. File moves stopped."));
const plan = planDrop(entry.rel_path, target, place, namesIn);
if (plan.action === "noop") return;
if (plan.action === "reorder") {
@@ -567,7 +567,7 @@
const next = moveMarks(current, plan.from, plan.to);
return { ...next, order: { ...next.order, [plan.fromParent]: plan.orderFrom, [plan.toParent]: plan.orderTo } };
});
if (!moved || workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
if (!moved || workspaceRoot !== operationRoot) throw new Error($t("The workspace changed. File moves stopped."));
moves.push({ from: plan.from, to: plan.to });
paths.set(plan.from, plan.to);
await load(plan.fromParent);
@@ -578,7 +578,7 @@
if (place === "inside") expanded = new Set([...expanded, destination]);
selection = { paths: new Set(paths.values()), anchor: paths.values().next().value ?? null };
error = result.failures.length ? result.failures.join("\n") : null;
onStatus?.(`Moved ${result.completed.length} of ${entries.length} items`);
onStatus?.($t("Moved {count} of {total} items", { count: result.completed.length, total: entries.length }));
if (moves.length || JSON.stringify(before.order) !== JSON.stringify(marks.order)) {
undoMoves = [...undoMoves, { moves, before, after: session.marks.snapshot() }];
redoMoves = [];
@@ -621,13 +621,13 @@
const applied: { from: string; to: string }[] = [];
try {
for (const move of redo ? batch.moves : [...batch.moves].reverse()) {
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
if (workspaceRoot !== operationRoot) throw new Error($t("The workspace changed. File moves stopped."));
const from = redo ? move.from : move.to, to = redo ? move.to : move.from;
// The batch restores the marks after all moves, so each move leaves them alone.
if (!await session.rename(from, to, null) || workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
if (!await session.rename(from, to, null) || workspaceRoot !== operationRoot) throw new Error($t("The workspace changed. File moves stopped."));
applied.push({ from, to });
}
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. File moves stopped.");
if (workspaceRoot !== operationRoot) throw new Error($t("The workspace changed. File moves stopped."));
await persistMarks(current => replayMoveMarks(current, batch.before, batch.after, batch.moves, redo));
if (redo) { redoMoves = redoMoves.slice(0, -1); undoMoves = [...undoMoves, batch]; }
else { undoMoves = undoMoves.slice(0, -1); redoMoves = [...redoMoves, batch]; }
@@ -657,11 +657,11 @@
const moves: MoveBatch["moves"] = [];
moving = true;
const result = await runTreeActions(source.paths.map(rel_path => ({ rel_path, name: rel_path.split("/").pop()!, kind: "file" as const })), async entry => {
if (workspaceRoot !== operationRoot) throw new Error("The workspace changed. Paste stopped.");
if (workspaceRoot !== operationRoot) throw new Error($t("The workspace changed. Paste stopped."));
if (source.cut) {
const to = joinRel(parent, entry.name);
if (to === entry.rel_path) return;
if (!await session.rename(entry.rel_path, to) || workspaceRoot !== operationRoot) throw new Error("The workspace changed. Paste stopped.");
if (!await session.rename(entry.rel_path, to) || workspaceRoot !== operationRoot) throw new Error($t("The workspace changed. Paste stopped."));
moves.push({ from: entry.rel_path, to });
} else await workspaceCopy(entry.rel_path, parent, operationRoot);
});
@@ -677,7 +677,7 @@
const result = await runTreeActions(roots, entry => workspaceCopy(entry.rel_path));
for (const parent of new Set(roots.map(entry => parentRel(entry.rel_path)))) await load(parent);
error = result.failures.length ? result.failures.join("\n") : null;
onStatus?.(`Copied ${result.completed.length} of ${roots.length} items`);
onStatus?.($t("Copied {count} of {total} items", { count: result.completed.length, total: roots.length }));
}
// Delete moves items to the system trash. One file needs no confirmation, because the
@@ -838,7 +838,7 @@
label: multiple ? $t("Copy workspace paths") : $t("Copy workspace path"),
icon: "copy",
run: () => {
void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? "workspace paths" : "workspace path");
void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? $t("Copied workspace paths") : $t("Copied workspace path"));
},
},
{
@@ -849,7 +849,7 @@
void (async () => {
try {
const paths = await Promise.all(entries.map(item => workspaceAbsPath(item.rel_path)));
await copyText(paths.join("\n"), multiple ? "system paths" : "system path");
await copyText(paths.join("\n"), multiple ? $t("Copied system paths") : $t("Copied system path"));
} catch (err) {
error = err instanceof Error ? err.message : String(err);
}