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:
@@ -286,27 +286,27 @@
|
||||
* The source tab closes only after this window accepts the tab.
|
||||
*/
|
||||
async function acceptTabTransfer(id: string, { index, startup = false }: { index?: number; startup?: boolean } = {}) {
|
||||
if (!TAB_TRANSFER_ID.test(id)) throw new Error("Invalid tab transfer.");
|
||||
if (!TAB_TRANSFER_ID.test(id)) throw new Error($t("Invalid tab transfer."));
|
||||
const current = documents;
|
||||
if (!workspace || !current || (switching && !startup)) throw new Error("Move tabs only between windows of the same workspace.");
|
||||
if (!workspace || !current || (switching && !startup)) throw new Error($t("Move tabs only between windows of the same workspace."));
|
||||
const payload = await takeTabTransfer(id, workspace.root);
|
||||
let accepted = false;
|
||||
try {
|
||||
const transfer = parseTabTransfer(payload);
|
||||
let path = "";
|
||||
if ("buffer" in transfer) {
|
||||
if (!current.importTab(transfer.buffer)) throw new Error("This tab is already open in this window. The source tab remains open.");
|
||||
if (!current.importTab(transfer.buffer)) throw new Error($t("This tab is already open in this window. The source tab remains open."));
|
||||
path = transfer.buffer.relPath;
|
||||
if (!startup) selectTab(path);
|
||||
} else {
|
||||
// A new window starts its plugins after the workspace opens. Wait for them there.
|
||||
const deadline = Date.now() + (startup ? 15000 : 0);
|
||||
while (!await restorePluginTab(transfer.plugin as Parameters<typeof restorePluginTab>[0])) {
|
||||
if (Date.now() >= deadline) throw new Error("Enable this tab's plugin before moving it to this window.");
|
||||
if (Date.now() >= deadline) throw new Error($t("Enable this tab's plugin before moving it to this window."));
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
if (index !== undefined) {
|
||||
if (!$pluginView || $pluginView.placement !== "editor") throw new Error("The plugin did not open this tab.");
|
||||
if (!$pluginView || $pluginView.placement !== "editor") throw new Error($t("The plugin did not open this tab."));
|
||||
path = `plugin:${$pluginView.key}`;
|
||||
}
|
||||
}
|
||||
@@ -450,7 +450,7 @@
|
||||
if (tab.plugin && await openPluginDocument(tab.path)) {
|
||||
await tick();
|
||||
const opened = $pluginEditors.find(view => view.document?.path === tab.path);
|
||||
if (!opened) throw new Error("The plugin did not open this document.");
|
||||
if (!opened) throw new Error($t("The plugin did not open this document."));
|
||||
if (tab.pinned !== !!opened.pinned) pinPluginEditor(opened.key);
|
||||
order.push(opened.key);
|
||||
paths.set(tab.path, `plugin:${opened.key}`);
|
||||
@@ -567,7 +567,7 @@
|
||||
const offered = offerTabTransfer(token, workspace!.root, { ...("buffer" in tab ? { buffer: tab.buffer } : { plugin: pluginTabState(tab.plugin) }), reading });
|
||||
// A drag cannot wait for the offer. Report a failed drag offer here. `detachTab` reports its own.
|
||||
offered.catch(reason => { finish(false); if (!reportTimeout) error = String(reason); });
|
||||
timer = setTimeout(() => { finish(); if (reportTimeout) error = "The new window did not accept the tab. The source tab remains open."; }, 30000);
|
||||
timer = setTimeout(() => { finish(); if (reportTimeout) error = $t("The new window did not accept the tab. The source tab remains open."); }, 30000);
|
||||
return { token, finish, offered };
|
||||
} catch (reason) { finish(); throw reason; }
|
||||
}
|
||||
@@ -902,7 +902,7 @@
|
||||
async function renameNoteTitle(id: string, title: string) {
|
||||
const current = documents;
|
||||
const note = current?.buffers.find(tab => tab.id === id);
|
||||
if (!current || !note || switching) throw new Error("This note is no longer available.");
|
||||
if (!current || !note || switching) throw new Error($t("This note is no longer available."));
|
||||
const from = note.relPath;
|
||||
const plan = planMarkdownTitleRename(from, title);
|
||||
if (plan.action === "error") throw new Error(plan.message);
|
||||
@@ -947,7 +947,7 @@
|
||||
const targets = await session.linkTargets(origin, link.target, link.kind);
|
||||
if ("ambiguous" in targets) throw new Error($t("More than one note matches {path}. Use its workspace path: {candidates}", { path: link.target, candidates: targets.ambiguous.join(", ") }));
|
||||
for (const path of targets.paths) {
|
||||
if (!valid()) throw new Error("The workspace changed. Open the link menu again.");
|
||||
if (!valid()) throw new Error($t("The workspace changed. Open the link menu again."));
|
||||
const parent = path.split("/").slice(0, -1).join("/");
|
||||
let files: TreeEntry[];
|
||||
try { files = await workspaceList(parent); } catch { continue; }
|
||||
@@ -965,7 +965,7 @@
|
||||
if (!typed || !valid()) return;
|
||||
let to = typed.trim().replaceAll("\\", "/");
|
||||
if (move) {
|
||||
if (!to || to.startsWith("/") || to.split("/").some(part => !part || part === "." || part === "..") || /[<>:"|?*\u0000-\u001f]/.test(to)) throw new Error("Enter a relative workspace path without reserved characters.");
|
||||
if (!to || to.startsWith("/") || to.split("/").some(part => !part || part === "." || part === "..") || /[<>:"|?*\u0000-\u001f]/.test(to)) throw new Error($t("Enter a relative workspace path without reserved characters."));
|
||||
} else {
|
||||
const plan = planRename(file.rel_path, to);
|
||||
if (plan.action === "noop") return;
|
||||
@@ -1071,18 +1071,18 @@
|
||||
({ leftOpen, rightOpen, leftWidth, rightWidth, leftView } = layout);
|
||||
if (transferredWindow) { leftOpen = false; rightOpen = false; }
|
||||
layoutReady = true;
|
||||
} catch { error = "Could not read your layout. Default layout applies for this window."; }
|
||||
} catch { error = $t("Could not read your layout. Default layout applies for this window."); }
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!layoutReady || transferredWindow) return;
|
||||
try { saveWorkbenchLayout(localStorage, { leftOpen, rightOpen, leftWidth, rightWidth, leftView }); }
|
||||
catch { error = "Could not save your layout. Layout changes apply for this window only."; }
|
||||
catch { error = $t("Could not save your layout. Layout changes apply for this window only."); }
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
try { settings = readSettings(); }
|
||||
catch { error = "Could not read your settings. Default settings apply until you save new settings."; }
|
||||
catch { error = $t("Could not read your settings. Default settings apply until you save new settings."); }
|
||||
error = takeSettingsNotice() ?? error;
|
||||
settingsReady = true;
|
||||
const stopSettings = onSettingsChange("general", () => { settings = readSettings(); });
|
||||
@@ -1109,11 +1109,11 @@
|
||||
}));
|
||||
unlisteners.push(handlePluginDocumentRename(async (from, name) => {
|
||||
const current = documents;
|
||||
if (!current || switching) throw new Error("Open a workspace before renaming a document.");
|
||||
if (!current || switching) throw new Error($t("Open a workspace before renaming a document."));
|
||||
const plan = planDocumentTitleRename(from, name);
|
||||
if (plan.action === "error") throw new Error(plan.message);
|
||||
if (plan.action === "noop") return from;
|
||||
if (!await session.rename(from, plan.to) || documents !== current) throw new Error("The workspace changed. Reopen the document.");
|
||||
if (!await session.rename(from, plan.to) || documents !== current) throw new Error($t("The workspace changed. Reopen the document."));
|
||||
return plan.to;
|
||||
}));
|
||||
unlisteners.push(guardPluginWrites(path => {
|
||||
@@ -1365,7 +1365,7 @@
|
||||
onRenameTitle={renameNoteTitle}
|
||||
tableActions={{ onSearch: searchSelection, onExtract: (markdown, label, valid) => extractSelection(markdown, label, valid, pane.buffer) }}
|
||||
linkActions={{
|
||||
browser: browserContribution ? async target => { if (!await browserContribution?.open(target)) throw new Error("Could not open the app browser."); } : undefined,
|
||||
browser: browserContribution ? async target => { if (!await browserContribution?.open(target)) throw new Error($t("Could not open the app browser.")); } : undefined,
|
||||
defaultBrowser: target => openUrl(target),
|
||||
workspaceItems: link => workspaceLinkItems(link, pane.buffer?.relPath ?? "", pane.id),
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user