editor i18n: English and Chinese (i18next; the English text is the key, zh-CN.json maps it; the browser's language unless chosen in the header, remembered); the chrome, notices, feature dialog, command bar and the operation catalog (names, groups, fields, options, descriptions) translated, a Chinese query finds operations by their Chinese names; a test fails when a literal key has no Chinese entry. Not yet: the assembly panel, sketch mode and the selection hints

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiJingzhe
2026-11-05 22:17:51 +08:00
parent 37a3fe97b4
commit 8e48abd140
30 changed files with 1334 additions and 251 deletions
+76 -1
View File
@@ -21,9 +21,11 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"fflate": "^0.8.3",
"i18next": "^26.7.1",
"lucide-react": "^1.48.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-i18next": "^17.1.12",
"react-resizable-panels": "^4.13.3",
"tailwind-merge": "^3.7.0",
"tailwindcss": "^4.3.3",
@@ -3414,6 +3416,43 @@
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
},
"node_modules/html-parse-stringify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-4.0.1.tgz",
"integrity": "sha512-0zHsZJrK7S3K2aucXWL6ycoYJ/iNtIcFHC/nYQgFklPtrv5LpJctIiSCroWZWeuoXvuyFdzp6KzjJQ+OT5MfFw==",
"license": "MIT",
"funding": {
"url": "https://locize.com"
}
},
"node_modules/i18next": {
"version": "26.7.1",
"resolved": "https://registry.npmjs.org/i18next/-/i18next-26.7.1.tgz",
"integrity": "sha512-cX+3RRVczel/V2kCMTACckSGSpqgtWYEA6beXNYVms7dOQiHojdPYHD26lT4IKimNeoGWrLvtPgjftbRvmZJVw==",
"funding": [
{
"type": "individual",
"url": "https://www.locize.com/i18next"
},
{
"type": "individual",
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
},
{
"type": "individual",
"url": "https://www.locize.com"
}
],
"license": "MIT",
"peerDependencies": {
"typescript": "^5 || ^6 || ^7"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/jiti": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
@@ -3856,6 +3895,33 @@
"react": "^19.3.0"
}
},
"node_modules/react-i18next": {
"version": "17.1.12",
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-17.1.12.tgz",
"integrity": "sha512-Gf8riCKF/EmqQ8I1g0N5pJOLvJCkAXGAEkzOuRNHc/sBGL3dfE3WZ7+sDLrUo/kw/xdug3g48jo7M+s/SKf0HQ==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.29.7",
"html-parse-stringify": "^4.0.1",
"use-sync-external-store": "^1.6.0"
},
"peerDependencies": {
"i18next": ">= 26.2.0",
"react": ">= 16.8.0",
"typescript": "^5 || ^6 || ^7"
},
"peerDependenciesMeta": {
"react-dom": {
"optional": true
},
"react-native": {
"optional": true
},
"typescript": {
"optional": true
}
}
},
"node_modules/react-remove-scroll": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.7.2.tgz",
@@ -4099,7 +4165,7 @@
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
"dev": true,
"devOptional": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
@@ -4161,6 +4227,15 @@
}
}
},
"node_modules/use-sync-external-store": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.7.0.tgz",
"integrity": "sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==",
"license": "MIT",
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/vite": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.3.1.tgz",
+2
View File
@@ -25,9 +25,11 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"fflate": "^0.8.3",
"i18next": "^26.7.1",
"lucide-react": "^1.48.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-i18next": "^17.1.12",
"react-resizable-panels": "^4.13.3",
"tailwind-merge": "^3.7.0",
"tailwindcss": "^4.3.3",
+39 -37
View File
@@ -57,6 +57,7 @@ import { cn } from "@/lib/utils";
import { Boxes, Cable } from "lucide-react";
import { Viewport, type PickResult, type SelectionMode } from "@/scene/Viewport";
import type { SceneView } from "@/scene/scene-view";
import { t, useI18n } from "@/i18n";
/** The pick intents and their keys: 1 vertex, 2 edge, 3 face, 4 solid (Plasticity's order), 5 component, 6 sketch. */
const MODES: { mode: SelectionMode; label: string; key: string }[] = [
@@ -77,6 +78,7 @@ const MANUAL_TABS = ["features", "assembly"];
const CODE_TABS = ["notebook", "module"];
export function App() {
useI18n(); // a change of language renders the whole editor again
const viewRef = useRef<SceneView | null>(null);
// Whether a model of the open notebook is on screen (it may be the last run's,
// restored while the kernel boots): then nothing is being waited for.
@@ -119,7 +121,7 @@ export function App() {
// kernel is up, and a late answer of the workspace list cannot undo it.
const [currentPath, setCurrentPath] = useState<string | null>(null);
const [kernelAlive, setKernelAlive] = useState(false);
const [status, setStatus] = useState("Connecting…");
const [status, setStatus] = useState(() => t("Connecting…"));
const [params, setParams] = useState<ParamMeta[]>([]);
const [cells, setCells] = useState<NotebookCell[]>([]);
@@ -222,7 +224,7 @@ export function App() {
const handleStop = useCallback(() => {
socketRef.current?.send({ type: "interrupt.request" });
setLoading(null);
log.push("info", "stop requested");
log.push("info", t("stop requested"));
log.resetBatch();
}, [log.push, log.resetBatch]);
@@ -256,9 +258,9 @@ export function App() {
framedNotebook.current = name;
}
setSceneVersion((version) => version + 1);
log.push("ok", `model shown: ${preview.nodes.length} ${preview.nodes.length === 1 ? "part" : "parts"}`);
log.push("ok", preview.nodes.length === 1 ? t("model shown: 1 part") : t("model shown: {{count}} parts", { count: preview.nodes.length }));
} catch (error) {
log.push("error", error instanceof Error ? error.message : "unable to open the preview");
log.push("error", error instanceof Error ? error.message : t("unable to open the preview"));
}
}, [log.push]);
@@ -284,9 +286,9 @@ export function App() {
refreshFeatures();
// No notebook: nothing to wait for. Else the model is on its way.
if (hasModel.current) return;
const stage = envelope["notebook"] ? (envelope["kernel"] ? "building the model" : "starting the kernel") : null;
const stage = envelope["notebook"] ? (envelope["kernel"] ? t("building the model") : t("starting the kernel")) : null;
setLoading(stage);
setStatus(stage ? `${stage[0].toUpperCase()}${stage.slice(1)}…` : "No notebook yet: create one in the workspace tab");
setStatus(stage ? `${stage}…` : t("No notebook yet: create one in the workspace tab"));
refreshWorkspace();
});
@@ -321,10 +323,10 @@ export function App() {
refreshFeatures();
setNotebook(String(envelope["notebook"] ?? ""));
setCurrentPath((envelope["path"] as string) ?? null);
setStatus(`opening ${envelope["notebook"]}…`);
setLoading(`opening ${envelope["notebook"]}`);
setStatus(`${t("opening {{name}}", { name: envelope["notebook"] })}…`);
setLoading(t("opening {{name}}", { name: envelope["notebook"] }));
log.resetBatch();
log.push("info", `opening ${envelope["notebook"]}`);
log.push("info", t("opening {{name}}", { name: envelope["notebook"] }));
setSceneVersion((version) => version + 1);
refreshWorkspace();
});
@@ -371,7 +373,7 @@ export function App() {
// The server dropped an edit made on a cell that had changed on disk.
socket.on("cell.conflict", (envelope) => {
const mine = String(envelope["mine"] ?? "");
log.push("error", `a cell changed on disk while you were editing it: kept the file's version. Your unsaved text was:\n${mine.length > 600 ? `${mine.slice(0, 600)}…` : mine}`);
log.push("error", `${t("a cell changed on disk while you were editing it: kept the file's version. Your unsaved text was:")}\n${mine.length > 600 ? `${mine.slice(0, 600)}…` : mine}`);
});
socket.on("notebook.features", (envelope) => setFeatures((envelope["features"] as NotebookFeature[]) ?? []));
socket.on("workplanes", (envelope) => setWorkplanes(parseWorkplanes(envelope["workplanes"])));
@@ -387,7 +389,7 @@ export function App() {
const nextPartial = parsePartial(envelope["partial"]);
if (nextPartial && !samePartial(partialRef.current, nextPartial)) {
const { title, reason } = describePartial(nextPartial);
log.push("info", `showing ${title.charAt(0).toLowerCase()}${title.slice(1)}: ${reason}`);
log.push("info", t("showing {{what}}: {{reason}}", { what: title, reason }));
}
partialRef.current = nextPartial;
setPartial(nextPartial);
@@ -425,18 +427,18 @@ export function App() {
setLoading(null);
}
} else if (typeof envelope["info"] === "string") {
setStatus(envelope["info"]);
log.push("info", envelope["info"]);
setStatus(t(envelope["info"]));
log.push("info", t(envelope["info"]));
setLoading(null); // a notice ends a wait as well (an empty notebook has no model to wait for)
} else if (typeof envelope["working"] === "string") {
setStatus(envelope["working"]);
log.push("run", envelope["working"]);
setLoading(envelope["working"].replace(/…$/, ""));
} else if (typeof envelope["exported"] === "string") {
setStatus(`exported ${envelope["exported"]}`);
setStatus(t("exported {{path}}", { path: envelope["exported"] }));
log.push("ok", `exported ${envelope["exported"]}`);
} else if (typeof envelope["created"] === "string") {
setStatus(`created ${envelope["created"]}`);
setStatus(t("created {{path}}", { path: envelope["created"] }));
log.push("ok", `created ${envelope["created"]}`);
}
});
@@ -505,7 +507,7 @@ export function App() {
},
[resolveFace],
);
const refusal = (type: string | null) => `This face is ${type ? `a ${type.toLowerCase()}` : "curved"}: a sketch needs a flat face. Pick a flat face or a datum plane.`;
const refusal = (type: string | null) => (type ? t("This face is a {{type}}: a sketch needs a flat face. Pick a flat face or a datum plane.", { type: type.toLowerCase() }) : t("This face is curved: a sketch needs a flat face. Pick a flat face or a datum plane."));
/** While the sketch plane is being chosen a face pick means "sketch on this face" and never reaches the selection. */
const pickSketchFace = useCallback(
@@ -768,7 +770,7 @@ export function App() {
const workplaneFromSelection = useCallback(async () => {
const request = workplaneRequest(selectionRef.current);
if (!request) {
setBarNote("A workplane needs one flat face, a face and an edge, two parallel faces, three vertices or one edge.");
setBarNote(t("A workplane needs one flat face, a face and an edge, two parallel faces, three vertices or one edge."));
return;
}
setBarNote(null);
@@ -853,10 +855,10 @@ export function App() {
/** The bases a workplane can be placed on: the datum planes, every workplane of the notebook, and the picked face. */
const placeBases = useMemo<PlaceBase[]>(() => {
if (placing?.kind === "connector" && placing.face) return [{ value: "face", label: "picked face", frame: placing.face.frame }];
if (placing?.kind === "connector" && placing.face) return [{ value: "face", label: t("picked face"), frame: placing.face.frame }];
const out: PlaceBase[] = (["XY", "XZ", "YZ"] as const).map((name) => ({ value: name, label: name, frame: NAMED_FRAMES[name] }));
for (const wp of workplanes) out.push({ value: wp.name, label: wp.name, frame: { origin: wp.origin, x_axis: wp.x_axis, y_axis: wp.y_axis, normal: wp.normal } });
if (placing?.face) out.push({ value: "face", label: "picked face", frame: placing.face.frame });
if (placing?.face) out.push({ value: "face", label: t("picked face"), frame: placing.face.frame });
return out;
}, [workplanes, placing?.face, placing?.kind]);
const placeBase = placeBases.find((item) => item.value === placing?.base) ?? placeBases[0];
@@ -869,7 +871,7 @@ export function App() {
const face = items.length === 1 && items[0].kind === "face" ? items[0] : null;
const frame = face ? faceFrame(face.properties) : null;
if (face && !frame) {
setBarNote("That face is not flat: a workplane lies on a plane. Pick a flat face, or nothing to place one on the active workplane.");
setBarNote(t("That face is not flat: a workplane lies on a plane. Pick a flat face, or nothing to place one on the active workplane."));
return;
}
const taken = gui.state?.taken ?? [];
@@ -887,7 +889,7 @@ export function App() {
const face = items.length === 1 && items[0].kind === "face" ? items[0] : null;
const frame = face ? connectorFrameFromFace(face) : null;
if (!face || !frame) {
setBarNote("A connector is placed on one flat face: pick it first (face mode).");
setBarNote(t("A connector is placed on one flat face: pick it first (face mode)."));
return;
}
setBarNote(null);
@@ -1162,9 +1164,9 @@ export function App() {
/** A command from the assembly panel: rejects with the server's message (shown in the panel). */
const runPanelCommand = useCallback(
async (command: FeatureCommand) => {
if (noNotebook()) throw new Error("No notebook is open: create one first.");
if (noNotebook()) throw new Error(t("No notebook is open: create one first."));
const result = await gui.run(command);
log.push("ok", command.op === "set_connectors" ? "connectors set" : `${command.op} ${result.name}`);
log.push("ok", command.op === "set_connectors" ? t("connectors set") : `${command.op} ${result.name}`);
if (isCellCommand(command)) assertCellRan(result);
},
[gui.run, log.push, noNotebook],
@@ -1245,15 +1247,15 @@ export function App() {
// -- actions -----------------------------------------------------------------------
const handleOpen = (path: string) => {
setStatus(`opening ${path}…`);
setStatus(`${t("opening {{name}}", { name: path })}…`);
openNotebook(path).catch((error) => {
log.push("error", `open failed: ${error.message}`);
log.push("error", t("open failed: {{reason}}", { reason: error.message }));
setLoading(null);
});
};
const handleCreate = async (name: string, kind: "part" | "assembly") => {
setStatus(`creating ${name}…`);
setStatus(`${t("creating {{name}}", { name })}…`);
await newNotebook(name, kind);
// the server opens it: show its features (manual mode) or its cells (code mode)
setLeftTab(mode === "manual" ? "features" : "notebook");
@@ -1268,14 +1270,14 @@ export function App() {
<TabsList className={floating ? "pr-8" : undefined}>
{mode === "manual" ? (
<>
<TabsTrigger value="features">features</TabsTrigger>
<TabsTrigger value="assembly">assembly</TabsTrigger>
<TabsTrigger value="workspace">workspace</TabsTrigger>
<TabsTrigger value="features">{t("features")}</TabsTrigger>
<TabsTrigger value="assembly">{t("assembly")}</TabsTrigger>
<TabsTrigger value="workspace">{t("workspace")}</TabsTrigger>
</>
) : (
<>
<TabsTrigger value="notebook">notebook</TabsTrigger>
<TabsTrigger value="workspace">workspace</TabsTrigger>
<TabsTrigger value="notebook">{t("notebook")}</TabsTrigger>
<TabsTrigger value="workspace">{t("workspace")}</TabsTrigger>
{moduleView && <TabsTrigger value="module">{moduleView.name}</TabsTrigger>}
</>
)}
@@ -1334,7 +1336,7 @@ export function App() {
onCreate={handleCreate}
onDelete={async (path) => {
const { trash } = await deleteNotebook(path);
log.push("ok", `deleted ${path} (kept in ${trash})`);
log.push("ok", t("deleted {{path}} (kept in {{trash}})", { path, trash }));
}}
/>
</TabsContent>
@@ -1362,20 +1364,20 @@ export function App() {
: "border-transparent text-muted-foreground hover:border-input hover:text-foreground",
)}
onClick={() => setSelectionMode(mode)}
title={`${label} (${key})`}
title={`${t(label)} (${key})`}
>
{label}
{t(label)}
<span className="ml-1 opacity-50">{key}</span>
</button>
))}
{!floating && <span className="flex-1" />}
{!floating && <span className="label hidden xl:inline">ctrl+click: add</span>}
{!floating && <span className="label hidden xl:inline">{t("ctrl+click: add")}</span>}
<button
type="button"
className="border-2 border-transparent px-2 py-px text-[10px] font-semibold uppercase tracking-[0.1em] text-muted-foreground hover:border-input hover:text-foreground"
onClick={() => viewRef.current?.frame()}
>
fit
{t("fit")}
</button>
</>
);
@@ -1400,7 +1402,7 @@ export function App() {
running={running}
onStop={handleStop}
onRunAll={() => {
setLoading("running all cells");
setLoading(t("running all cells"));
socketRef.current?.send({ type: "rerun.request" });
}}
/>
+4 -3
View File
@@ -4,6 +4,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { enterRunsFirst, placeBar, type Size } from "@/lib/action-bar";
import { cn } from "@/lib/utils";
import { t } from "@/i18n";
export type BarAction = {
id: string;
@@ -71,7 +72,7 @@ export function ActionBar({
<div
ref={ref}
role="toolbar"
aria-label={title ?? "Actions for the selection"}
aria-label={title ?? t("Actions for the selection")}
data-testid="action-bar"
data-docked={at.docked}
className={cn("pointer-events-auto absolute z-20 flex max-w-[92%] flex-col gap-1", className)}
@@ -91,12 +92,12 @@ export function ActionBar({
className="h-7 px-2"
data-action={action.id}
aria-disabled={Boolean(action.disabled)}
title={action.disabled ?? action.hint ?? action.label}
title={t(action.disabled ?? action.hint ?? action.label)}
onClick={() => (action.disabled ? setWhy({ id: action.id, text: action.disabled }) : action.run())}
style={action.disabled ? { opacity: 0.45 } : undefined}
>
{Icon && <Icon />}
{action.label}
{t(action.label)}
{isFirst && enter && <kbd className="ml-0.5 border border-current px-1 text-[9px] opacity-70">enter</kbd>}
</Button>
);
+24 -23
View File
@@ -23,6 +23,7 @@ import { createSettler, SETTLE_MS } from "@/lib/settle";
import { cadTheme } from "@/lib/cm-theme";
import { sdkCompletion } from "@/lib/sdk-complete";
import { cn } from "@/lib/utils";
import { t } from "@/i18n";
export type NotebookCell = {
id: string;
@@ -230,22 +231,22 @@ export function CellEditor({
}, [armed]);
if (cells.length === 0) {
return <p className="p-3 text-[11px] text-muted-foreground">Waiting for the kernel to publish cells…</p>;
return <p className="p-3 text-[11px] text-muted-foreground">{t("Waiting for the kernel to publish cells…")}</p>;
}
const allCollapsed = cells.every((cell) => collapsed.has(cell.id));
return (
<div className="flex h-full flex-col">
<div className="flex h-8 shrink-0 items-center justify-between border-b border-border px-3">
<span className="label">{cells.length} cells</span>
<span className="label">{cells.length === 1 ? t("1 cell") : t("{{count}} cells", { count: cells.length })}</span>
<button
type="button"
className="label flex items-center gap-1 hover:text-foreground"
title={allCollapsed ? "Unfold every cell" : "Fold every cell to its name"}
title={allCollapsed ? t("Unfold every cell") : t("Fold every cell to its name")}
onClick={() => remember(allCollapsed ? new Set() : new Set(cells.map((cell) => cell.id)))}
>
{allCollapsed ? <ChevronsUpDown className="h-3 w-3" /> : <ChevronsDownUp className="h-3 w-3" />}
{allCollapsed ? "unfold all" : "fold all"}
{allCollapsed ? t("unfold all") : t("fold all")}
</button>
</div>
<ScrollArea className="min-h-0 flex-1">
@@ -288,7 +289,7 @@ function CellGap({ after, onInsert }: { after: string | null; onInsert: (after:
<div className="absolute inset-x-0 h-[2px] bg-transparent transition-colors group-hover/gap:bg-border" />
<button
type="button"
title="Insert a cell here"
title={t("Insert a cell here")}
className="z-10 flex h-4 w-4 items-center justify-center border-2 border-input bg-background text-muted-foreground opacity-0 transition-opacity hover:border-focus hover:text-focus group-hover/gap:opacity-100"
onClick={(event) => {
event.stopPropagation();
@@ -407,39 +408,39 @@ function CellBlock({
type="button"
className="flex min-w-0 flex-1 items-center gap-1.5 self-stretch pl-1.5 text-left"
onClick={onToggle}
title={folded ? "Unfold" : "Fold to its name"}
title={folded ? t("Unfold") : t("Fold to its name")}
>
<ChevronRight className={cn("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform", !folded && "rotate-90")} />
<span className="w-5 shrink-0 text-[10px] text-muted-foreground">{String(index + 1).padStart(2, "0")}</span>
<span className={cn("truncate font-semibold", isSelection ? "text-focus" : "text-name")}>{title}</span>
{role && <span className="label shrink-0">{role}</span>}
</button>
{dirty && <span className="h-2 w-2 shrink-0 bg-focus" title="saving…" />}
{cell.status === "running" && <Badge variant="focus" className="animate-pulse">running</Badge>}
{cell.status === "queued" && <Badge variant="secondary">queued</Badge>}
{failed && <Badge variant="fail">failed</Badge>}
{cell.blocked && !failed && <Badge variant="secondary">blocked</Badge>}
{stale && !failed && <Badge variant="focus">stale</Badge>}
{cell.readonly && <Badge variant="secondary">function</Badge>}
{dirty && <span className="h-2 w-2 shrink-0 bg-focus" title={t("saving…")} />}
{cell.status === "running" && <Badge variant="focus" className="animate-pulse">{t("running")}</Badge>}
{cell.status === "queued" && <Badge variant="secondary">{t("queued")}</Badge>}
{failed && <Badge variant="fail">{t("failed")}</Badge>}
{cell.blocked && !failed && <Badge variant="secondary">{t("blocked")}</Badge>}
{stale && !failed && <Badge variant="focus">{t("stale")}</Badge>}
{cell.readonly && <Badge variant="secondary">{t("function")}</Badge>}
<button
type="button"
title="Copy a reference to this cell for a coding agent (Alt/Shift+click: with its code)"
title={t("Copy a reference to this cell for a coding agent (Alt/Shift+click: with its code)")}
className="flex h-6 w-6 shrink-0 items-center justify-center border-2 border-transparent text-muted-foreground transition-colors hover:border-input hover:text-foreground"
onClick={(event) => copyReference(event.altKey || event.shiftKey)}
>
{copied ? <Check className="h-3.5 w-3.5 text-pass" /> : <Copy className="h-3.5 w-3.5" />}
</button>
<IconButton title="Run every cell above this one" onClick={onRunAbove} disabled={index === 0}>
<IconButton title={t("Run every cell above this one")} onClick={onRunAbove} disabled={index === 0}>
<ChevronsUp className="h-3.5 w-3.5" />
</IconButton>
{/* One button, two states: run, and while the kernel is running the cell, stop. */}
<IconButton
title={
live
? "Stop the run (interrupt the kernel)"
? t("Stop the run (interrupt the kernel)")
: failed
? "Cell failed — run again (Ctrl+Enter)"
: "Run this cell (Ctrl+Enter)"
? t("Cell failed — run again (Ctrl+Enter)")
: t("Run this cell (Ctrl+Enter)")
}
onClick={live ? onInterrupt : onRun}
className={live ? "border-fail text-fail hover:border-fail hover:text-fail" : undefined}
@@ -453,7 +454,7 @@ function CellBlock({
)}
</IconButton>
<IconButton
title={armed ? "Click again to delete this cell" : "Delete this cell"}
title={armed ? t("Click again to delete this cell") : t("Delete this cell")}
onClick={onDelete}
data-delete-armed={cell.id}
className={armed ? "border-fail bg-fail text-primary-foreground hover:border-fail hover:text-primary-foreground" : "hover:text-fail"}
@@ -502,22 +503,22 @@ function CellBlock({
<button
type="button"
className="label hover:text-foreground"
title="Drop the edited values; back to what the source says"
title={t("Drop the edited values; back to what the source says")}
onClick={() =>
socket?.send({ type: "param.revert", names: params.filter((p) => p.modified).map((p) => p.id) })
}
>
revert
{t("revert")}
</button>
<button
type="button"
className="label text-focus hover:text-foreground"
title="Write the edited values into the notebook source"
title={t("Write the edited values into the notebook source")}
onClick={() =>
socket?.send({ type: "param.commit", names: params.filter((p) => p.modified).map((p) => p.id) })
}
>
write to source
{t("write to source")}
</button>
</div>
)}
+15 -14
View File
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { commandGroups, pushRecent, searchCommands, type Command } from "@/lib/commands";
import { cn } from "@/lib/utils";
import { t } from "@/i18n";
const DOCK_KEY = "sca.commandbar.dock";
const RECENT_KEY = "sca.commandbar.recent";
@@ -135,11 +136,11 @@ export function CommandBar({ commands, fit, hint, belowTop = false }: { commands
<button
type="button"
className="pointer-events-auto flex items-center gap-1.5 border-2 border-primary bg-background px-3 py-1 text-[10px] font-semibold uppercase tracking-[0.1em] shadow-[4px_4px_0_var(--shadow-hard)] hover:border-focus"
title="Show the command bar (/ or Ctrl/Cmd+K)"
aria-label="Show the command bar"
title={t("Show the command bar (/ or Ctrl/Cmd+K)")}
aria-label={t("Show the command bar")}
onClick={() => setCollapsed(false)}
>
<ChevronsUpDown className="size-3.5" /> add feature
<ChevronsUpDown className="size-3.5" /> {t("add feature")}
</button>
</div>
);
@@ -147,12 +148,12 @@ export function CommandBar({ commands, fit, hint, belowTop = false }: { commands
return (
<div className={cn("pointer-events-none absolute inset-x-0 z-20 flex justify-center px-3", place)}>
<div ref={root} role="toolbar" aria-label="Command bar" className={cn("pointer-events-auto relative w-full max-w-[720px]", bottom ? "" : "")}>
<div ref={root} role="toolbar" aria-label={t("Command bar")} className={cn("pointer-events-auto relative w-full max-w-[720px]", bottom ? "" : "")}>
{shown.length > 0 && (
<ul
ref={listRef}
role="listbox"
aria-label="Operations"
aria-label={t("Operations")}
className={cn(
"absolute inset-x-0 overflow-y-auto border-2 border-primary bg-popover shadow-[4px_4px_0_var(--shadow-hard)]",
bottom ? "bottom-full mb-1" : "top-full mt-1",
@@ -173,9 +174,9 @@ export function CommandBar({ commands, fit, hint, belowTop = false }: { commands
onClick={() => run(command)}
>
{Icon ? <Icon className="size-3.5 shrink-0" /> : <span className="size-3.5 shrink-0" />}
<span className="shrink-0 font-semibold">{command.label}</span>
<span className={cn("min-w-0 flex-1 truncate text-[11px]", index === at ? "opacity-80" : "text-muted-foreground")}>{command.description}</span>
<span className={cn("shrink-0 text-[10px] uppercase tracking-[0.08em]", fit && fit(command) > 0 ? "font-bold" : "opacity-70")}>{fit && fit(command) > 0 ? "fits selection" : command.group}</span>
<span className="shrink-0 font-semibold">{t(command.label)}</span>
<span className={cn("min-w-0 flex-1 truncate text-[11px]", index === at ? "opacity-80" : "text-muted-foreground")}>{command.description ? t(command.description) : null}</span>
<span className={cn("shrink-0 text-[10px] uppercase tracking-[0.08em]", fit && fit(command) > 0 ? "font-bold" : "opacity-70")}>{fit && fit(command) > 0 ? t("fits selection") : t(command.group)}</span>
</li>
);
})}
@@ -205,7 +206,7 @@ export function CommandBar({ commands, fit, hint, belowTop = false }: { commands
setOpen(!same);
}}
>
{name}
{t(name)}
</button>
))}
</div>
@@ -217,8 +218,8 @@ export function CommandBar({ commands, fit, hint, belowTop = false }: { commands
value={query}
role="combobox"
aria-expanded={open}
aria-label="Search operations"
placeholder="Search operations"
aria-label={t("Search operations")}
placeholder={t("Search operations")}
spellCheck={false}
className="h-6 w-full border-2 border-input bg-background pl-6 pr-[78px] text-[12px] placeholder:text-muted-foreground focus-visible:border-focus focus-visible:outline-none"
onChange={(event) => {
@@ -231,13 +232,13 @@ export function CommandBar({ commands, fit, hint, belowTop = false }: { commands
onKeyDown={onInputKey}
/>
{!query && (
<kbd className="pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 border border-input px-1 text-[9px] uppercase text-muted-foreground">/ or Ctrl+K</kbd>
<kbd className="pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 border border-input px-1 text-[9px] uppercase text-muted-foreground">{t("/ or Ctrl+K")}</kbd>
)}
</label>
<button type="button" className="p-1 text-muted-foreground hover:text-foreground" aria-label={bottom ? "Dock at the top" : "Dock at the bottom"} title={bottom ? "Dock at the top" : "Dock at the bottom"} onClick={toggleDock}>
<button type="button" className="p-1 text-muted-foreground hover:text-foreground" aria-label={bottom ? t("Dock at the top") : t("Dock at the bottom")} title={bottom ? t("Dock at the top") : t("Dock at the bottom")} onClick={toggleDock}>
{bottom ? <PanelTop className="size-3.5" /> : <PanelBottom className="size-3.5" />}
</button>
<button type="button" className="p-1 text-muted-foreground hover:text-foreground" aria-label="Collapse the command bar" title="Collapse to a pill" onClick={() => { setOpen(false); setCollapsed(true); }}>
<button type="button" className="p-1 text-muted-foreground hover:text-foreground" aria-label={t("Collapse the command bar")} title={t("Collapse to a pill")} onClick={() => { setOpen(false); setCollapsed(true); }}>
<ChevronsDownUp className="size-3.5" />
</button>
</div>
+16 -15
View File
@@ -25,6 +25,7 @@ import { rayThrough } from "@/scene/camera-projection";
import { OVERLAY_LAYER } from "@/scene/renderer/brep-renderer";
import { pointSprites } from "@/scene/point-sprites";
import type { SceneView } from "@/scene/scene-view";
import { t } from "@/i18n";
const EMPTY: CurveDoc = { points: [], curves: [] };
const PATH = "#2563eb";
@@ -348,14 +349,14 @@ export function CurveDrawer({
const hint =
doc.points.length === 0
? "Click the first point."
? t("Click the first point.")
: tool === "arc"
? pending.length === 0
? "Click a point the arc passes through."
: "Click where the arc ends."
? t("Click a point the arc passes through.")
: t("Click where the arc ends.")
: tool === "spline"
? "Click the points the spline passes through; another tool or Enter ends it."
: "Click where the line ends.";
? t("Click the points the spline passes through; another tool or Enter ends it.")
: t("Click where the line ends.");
return (
<>
@@ -367,23 +368,23 @@ export function CurveDrawer({
)}
<div className="pointer-events-auto absolute left-3 top-3 z-30 flex max-w-[min(460px,90%)] flex-col gap-2 border-2 border-primary bg-popover px-3 py-2 text-[11px] shadow-[4px_4px_0_var(--shadow-hard)]" data-testid="curve-drawer">
<div className="scroll-row items-center gap-2">
<span className="font-semibold">3D curve</span>
<input id="curve-name" aria-label="name" className="w-20 border border-input bg-background px-1 font-mono" value={name} onChange={(event) => setName(event.target.value)} />
<span className="font-semibold">{t("3D curve")}</span>
<input id="curve-name" aria-label={t("name")} className="w-20 border border-input bg-background px-1 font-mono" value={name} onChange={(event) => setName(event.target.value)} />
<span className="flex border border-input">
{TOOLS.map((item) => (
<button
key={item.kind}
type="button"
title={`${item.label} (${item.key.toUpperCase()})`}
title={`${t(item.label)} (${item.key.toUpperCase()})`}
className={`flex items-center gap-1 px-1.5 ${tool === item.kind ? "bg-primary text-primary-foreground" : ""}`}
onClick={() => switchTool(item.kind)}
>
<item.icon className="size-3" /> {item.label}
<item.icon className="size-3" /> {t(item.label)}
</button>
))}
</span>
<span className="text-muted-foreground">on</span>
<select id="curve-plane" aria-label="drawing plane" className="border border-input bg-background px-1" value={plane?.name} onChange={(event) => setPlaneName(event.target.value)}>
<span className="text-muted-foreground">{t("on")}</span>
<select id="curve-plane" aria-label={t("drawing plane")} className="border border-input bg-background px-1" value={plane?.name} onChange={(event) => setPlaneName(event.target.value)}>
{planes.map((item) => (
<option key={item.name} value={item.name}>
{item.name}
@@ -392,17 +393,17 @@ export function CurveDrawer({
</select>
</div>
<span className="text-muted-foreground">
{hint} Snaps to vertices, edge midpoints, workplane origins, its own points and the grid. Tab: next plane · ⌫: back
{hint} {t("Snaps to vertices, edge midpoints, workplane origins, its own points and the grid. Tab: next plane · ⌫: back")}
</span>
<div className="flex items-center gap-2">
<button type="button" disabled={busy || doc.curves.length + (pending.length && tool === "spline" ? 1 : 0) === 0} className="border-2 border-primary bg-primary px-2 py-0.5 font-semibold text-primary-foreground disabled:opacity-50" onClick={finish}>
Finish (Enter)
{t("Finish")} (Enter)
</button>
<button type="button" className="border border-border px-2 py-0.5 hover:bg-accent" onClick={onCancel}>
Cancel (Esc)
{t("Cancel")} (Esc)
</button>
<span className="font-mono text-muted-foreground">
{doc.curves.length} {doc.curves.length === 1 ? "segment" : "segments"} · {nextId(doc.points.map((p) => p.id), "p")}
{doc.curves.length === 1 ? t("1 segment") : t("{{count}} segments", { count: doc.curves.length })} · {nextId(doc.points.map((p) => p.id), "p")}
</span>
</div>
{error && (
+9 -8
View File
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "react";
import { cn } from "@/lib/utils";
import type { LogEntry, LogLevel, RunBatch } from "@/lib/runlog";
import { t } from "@/i18n";
const INK: Record<LogLevel, string> = {
info: "text-muted-foreground",
@@ -61,11 +62,11 @@ export function Dock({
const percent = batch && batch.total > 0 ? Math.round((batch.done / batch.total) * 100) : 0;
return (
<section className="shrink-0 border-t-2 border-border bg-background" aria-label="log">
<section className="shrink-0 border-t-2 border-border bg-background" aria-label={t("log")}>
{open && (
<div ref={list} className="h-44 overflow-y-auto border-b-2 border-border px-3 py-1.5 text-[11px] leading-5">
{entries.length === 0 ? (
<p className="text-muted-foreground">Nothing yet. Runs, reloads and errors are listed here.</p>
<p className="text-muted-foreground">{t("Nothing yet. Runs, reloads and errors are listed here.")}</p>
) : (
entries.map((entry) => (
<p key={entry.id} className={cn("flex gap-3 whitespace-pre-wrap break-words", INK[entry.level])}>
@@ -82,20 +83,20 @@ export function Dock({
type="button"
className="flex min-w-0 flex-1 items-center gap-2 self-stretch text-left"
onClick={() => setOpen((value) => !value)}
title={open ? "Close the log" : "Open the log"}
title={open ? t("Close the log") : t("Open the log")}
>
{open ? <ChevronDown className="h-3.5 w-3.5 shrink-0" /> : <ChevronUp className="h-3.5 w-3.5 shrink-0" />}
<span className="label shrink-0">log</span>
<span className="label shrink-0">{t("log")}</span>
{batch ? (
<>
<span className="shrink-0 text-focus">
re-evaluating {batch.done}/{batch.total}
{t("re-evaluating {{done}}/{{total}}", { done: batch.done, total: batch.total })}
</span>
<span className="relative h-2 w-28 shrink-0 border border-focus">
<span className="absolute inset-y-0 left-0 bg-focus" style={{ width: `${percent}%` }} />
</span>
<span className="min-w-0 truncate text-muted-foreground">
{batch.current ? `${batch.current} · ` : batch.done >= batch.total ? "building the model · " : ""}
{batch.current ? `${batch.current} · ` : batch.done >= batch.total ? `${t("building the model")} · ` : ""}
{(Math.max(0, tick - batch.startedAt) / 1000).toFixed(1)} s
</span>
</>
@@ -107,12 +108,12 @@ export function Dock({
</button>
{errors > 0 && (
<span className="shrink-0 border border-fail px-1.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-fail">
{errors} {errors === 1 ? "error" : "errors"}
{errors === 1 ? t("1 error") : t("{{count}} errors", { count: errors })}
</span>
)}
<button
type="button"
title="Clear the log"
title={t("Clear the log")}
className="flex h-6 w-6 shrink-0 items-center justify-center border-2 border-transparent text-muted-foreground hover:border-input hover:text-foreground"
onClick={onClear}
>
+42 -41
View File
@@ -46,6 +46,7 @@ import type { SelectionItem } from "@/lib/selection";
import type { SelectionMode } from "@/scene/Viewport";
import type { SceneView } from "@/scene/scene-view";
import { HolePlacer, type HoleDraft } from "@/components/HolePlacer";
import { t } from "@/i18n";
/** The icon of each way a new solid meets the body (colour stays reserved for meaning, so the icons carry no ink). */
const OPERATION_ICONS: Record<string, LucideIcon> = { join: SquarePlus, cut: Scissors, intersect: Combine, new: Box };
@@ -259,9 +260,9 @@ function FeatureForm({
for (const slot of selectSlots) {
const picks = picksOf(slot);
if (replaced(slot)) {
if (picks.some((item) => !isDescribed(item))) selectionErrors[slot.name] = "details of the picked items are still loading";
if (picks.some((item) => !isDescribed(item))) selectionErrors[slot.name] = t("details of the picked items are still loading");
else selections[slot.name] = picks.map(pickedPayload);
} else if (!editing && !slot.optional) selectionErrors[slot.name] = `pick ${slot.entity === "edge" ? "edges" : "faces"} in the viewport`;
} else if (!editing && !slot.optional) selectionErrors[slot.name] = slot.entity === "edge" ? t("pick edges in the viewport") : t("pick faces in the viewport");
}
const allErrors = { ...errors, ...selectionErrors };
@@ -290,18 +291,18 @@ function FeatureForm({
const fillFromFace = () => {
const faces = filterSelection(selection, "face");
if (faces.length !== 1) {
setNote("Pick exactly one face in the viewport first.");
setNote(t("Pick exactly one face in the viewport first."));
return;
}
const face = faces[0];
if (!isDescribed(face)) {
setNote("The face details are still loading; try again in a moment.");
setNote(t("The face details are still loading; try again in a moment."));
return;
}
const { point, vector } = holeFromFace(face);
const direction = vector ? "face" : null;
if (!point) {
setNote("This face has no centroid; type the start point.");
setNote(t("This face has no centroid; type the start point."));
return;
}
setForm((previous) => ({
@@ -311,8 +312,8 @@ function FeatureForm({
}));
setNote(
direction && vector
? `Start point set from the face centroid; the hole follows the face's normal, into the material (${vector.map((v) => round4(v)).join(", ")}).`
: "Start point set from the face centroid. The face reports no normal: check the direction.",
? t("Start point set from the face centroid; the hole follows the face's normal, into the material ({{normal}}).", { normal: vector.map((v) => round4(v)).join(", ") })
: t("Start point set from the face centroid. The face reports no normal: check the direction."),
);
setServerError(null);
};
@@ -337,7 +338,7 @@ function FeatureForm({
position: point.map((c) => String(round4(c))),
...(previous.direction === "face" ? { dx: String(round4(-normal[0])), dy: String(round4(-normal[1])), dz: String(round4(-normal[2])) } : {}),
}));
setNote(`Start point placed at (${point.map((c) => round4(c)).join(", ")}).`);
setNote(t("Start point placed at ({{point}}).", { point: point.map((c) => round4(c)).join(", ") }));
setServerError(null);
};
@@ -377,12 +378,12 @@ function FeatureForm({
>
<DialogHeader>
<DialogTitle>
{editing ? "Edit" : "Add"} {plainLabel(spec.id, spec.label).toLowerCase()}
{editing ? t("Edit {{what}}", { what: t(plainLabel(spec.id, spec.label)).toLowerCase() }) : t("Add {{what}}", { what: t(plainLabel(spec.id, spec.label)).toLowerCase() })}
</DialogTitle>
<DialogDescription>{plainDescription(spec.id, spec.description)}</DialogDescription>
<DialogDescription>{t(plainDescription(spec.id, spec.description))}</DialogDescription>
</DialogHeader>
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 py-3">
<Field label="Name" error={touched ? nameError : null} help={editing ? "A feature keeps its name." : undefined}>
<Field label={t("Name")} error={touched ? nameError : null} help={editing ? t("A feature keeps its name.") : undefined}>
<Input
value={editing ? (edit?.slug ?? "") : name}
disabled={editing}
@@ -392,7 +393,7 @@ function FeatureForm({
/>
</Field>
{visibleSlots(spec, form).map((slot) => slot.name === TARGET_SLOT && spec.combinable && targetDisplay(combine, shaped, String(form[slot.name] ?? "")).kind === "hidden" ? null : (
<Field key={slot.name} label={combineLine(spec, slot, form, combine, shaped) ? "" : slot.label} unit={slot.kind === "point" ? slot.unit : undefined} help={(spec.id === "hole" && slot.name === "position" && note) || (spec.combinable && (slot.name === OPERATION_SLOT || slot.name === TARGET_SLOT)) ? undefined : slot.help} error={touched ? (allErrors[slot.name] ?? null) : null}>
<Field key={slot.name} label={combineLine(spec, slot, form, combine, shaped) ? "" : t(slot.label)} unit={slot.kind === "point" ? slot.unit : undefined} help={(spec.id === "hole" && slot.name === "position" && note) || (spec.combinable && (slot.name === OPERATION_SLOT || slot.name === TARGET_SLOT)) ? undefined : slot.help && t(slot.help)} error={touched ? (allErrors[slot.name] ?? null) : null}>
<SlotWidget
slot={slot}
form={form}
@@ -416,7 +417,7 @@ function FeatureForm({
{spec.id === "hole" && slot.name === "position" && (
<div className="mt-1 flex flex-col gap-1">
<Button type="button" size="sm" variant="outline" onClick={fillFromFace}>
<MousePointerClick /> use picked face
<MousePointerClick /> {t("use picked face")}
</Button>
{note && <span className="text-[11px] text-muted-foreground">{note}</span>}
</div>
@@ -431,10 +432,10 @@ function FeatureForm({
</div>
<DialogFooter>
<Button type="button" variant="ghost" size="sm" onClick={onClose}>
cancel
{t("cancel")}
</Button>
<Button type="button" size="sm" disabled={busy || (touched && invalid)} onClick={() => void submit()}>
{busy ? "working…" : editing ? "apply" : "add"}
{busy ? t("working…") : editing ? t("apply") : t("add")}
</Button>
</DialogFooter>
{holeDraft && view && <HolePlacer view={view} draft={holeDraft} onPlace={placeHole} />}
@@ -519,7 +520,7 @@ function SlotWidget({
const raw = form[slot.name];
if (slot.kind === "enum" && slot.name === OPERATION_SLOT && slot.options?.some((option) => option.value === "join")) {
const { options: choices, note } = operationOptions(slot.options, combine, edit);
return <OperationChooser options={choices} value={typeof raw === "string" ? raw : ""} onChange={(value) => set(slot.name, value)} icons={OPERATION_ICONS} label={slot.label} note={note} />;
return <OperationChooser options={choices} value={typeof raw === "string" ? raw : ""} onChange={(value) => set(slot.name, value)} icons={OPERATION_ICONS} label={t(slot.label)} note={note} />;
}
if (slot.kind === "body" && slot.name === TARGET_SLOT) {
const shown = targetDisplay(combine, edit, typeof raw === "string" ? raw : "");
@@ -527,7 +528,7 @@ function SlotWidget({
if (shown.kind === "fixed") {
return (
<span className="text-[12px]" data-testid="combined-with">
Combined with: <span className="text-name">{shown.name}</span>
{t("Combined with:")} <span className="text-name">{shown.name}</span>
</span>
);
}
@@ -545,18 +546,18 @@ function SlotWidget({
<SelectContent>
{(options ?? slot.options ?? []).map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
{t(option.label)}
</SelectItem>
))}
</SelectContent>
</Select>
{flip && (
<div className="flex items-center gap-2" data-testid="direction-flip" data-against={flip.against}>
<Button type="button" size="sm" variant="outline" className="h-6 px-2" data-testid="flip-direction" disabled={!flip.can} title="Push the other way (the arrow in the viewport turns)" onClick={onFlip}>
<ArrowUpDown /> flip
<Button type="button" size="sm" variant="outline" className="h-6 px-2" data-testid="flip-direction" disabled={!flip.can} title={t("Push the other way (the arrow in the viewport turns)")} onClick={onFlip}>
<ArrowUpDown /> {t("flip")}
</Button>
<span className="text-[11px] text-muted-foreground">
pushes <span className="text-focus">{flip.against ? "against" : "along"}</span> the sketch normal ({flip.axis}); the arrow in the viewport shows it
{flip.against ? t("pushes against the sketch normal ({{axis}}); the arrow in the viewport shows it", { axis: flip.axis }) : t("pushes along the sketch normal ({{axis}}); the arrow in the viewport shows it", { axis: flip.axis })}
</span>
</div>
)}
@@ -568,12 +569,12 @@ function SlotWidget({
return (
<Select value={typeof raw === "string" ? raw : ""} onValueChange={(value) => set(slot.name, value)}>
<SelectTrigger aria-invalid={invalid}>
<SelectValue placeholder="no body yet" />
<SelectValue placeholder={t("no body yet")} />
</SelectTrigger>
<SelectContent>
{open.length > 0 && (
<SelectGroup>
<SelectLabel>open bodies</SelectLabel>
<SelectLabel>{t("open bodies")}</SelectLabel>
{open.map((body) => (
<SelectItem key={body.name} value={body.name}>
{body.name}
@@ -583,7 +584,7 @@ function SlotWidget({
)}
{used.length > 0 && (
<SelectGroup>
<SelectLabel>already used</SelectLabel>
<SelectLabel>{t("already used")}</SelectLabel>
{used.map((body) => (
<SelectItem key={body.name} value={body.name}>
{body.name}
@@ -603,7 +604,7 @@ function SlotWidget({
return (
<div className="flex flex-col gap-1" data-testid={`value-list-${slot.name}`}>
<div className="flex flex-wrap gap-1">
{choices.length === 0 && <span className="text-[11px] text-muted-foreground">no {what} in this notebook yet</span>}
{choices.length === 0 && <span className="text-[11px] text-muted-foreground">{t("no {{what}} in this notebook yet", { what })}</span>}
{choices.map((choice) => {
const at = chosen.indexOf(choice.name);
return (
@@ -614,7 +615,7 @@ function SlotWidget({
variant={at >= 0 ? "default" : "outline"}
className="h-6 px-2"
aria-pressed={at >= 0}
title={at >= 0 ? `#${at + 1}: click to leave it out` : "click to add it (the order of the clicks is the order)"}
title={at >= 0 ? t("#{{n}}: click to leave it out", { n: at + 1 }) : t("click to add it (the order of the clicks is the order)")}
onClick={() => set(slot.name, at >= 0 ? chosen.filter((n) => n !== choice.name) : [...chosen, choice.name])}
>
{at >= 0 && <span className="text-[10px]">{at + 1}</span>}
@@ -623,14 +624,14 @@ function SlotWidget({
);
})}
</div>
<span className="text-[11px] text-muted-foreground">{what}, in the order clicked</span>
<span className="text-[11px] text-muted-foreground">{t("{{what}}, in the order clicked", { what })}</span>
</div>
);
}
return (
<Select value={typeof raw === "string" ? raw : ""} onValueChange={(value) => set(slot.name, value)}>
<SelectTrigger aria-invalid={invalid}>
<SelectValue placeholder={`no ${what} yet`} />
<SelectValue placeholder={t("no {{what}} yet", { what })} />
</SelectTrigger>
<SelectContent>
{choices.map((choice) => (
@@ -669,7 +670,7 @@ function SlotWidget({
<span className="text-[12px] text-muted-foreground">{hex ? hex : slot.optional ? "unchanged" : "none"}</span>
{hex && slot.optional && (
<Button type="button" size="sm" variant="outline" className="h-6 px-2" onClick={() => set(slot.name, "")}>
clear
{t("clear")}
</Button>
)}
</div>
@@ -685,15 +686,15 @@ function SlotWidget({
<div className="flex flex-col gap-1">
<div className="flex items-center gap-2 border-2 border-input px-2 py-1" data-testid="sketch-field" data-armed={armed}>
<span className="min-w-0 flex-1 truncate text-[12px]">
Sketch: {chosen ? <span className="text-name">{chosen.name}</span> : <span className="text-muted-foreground">none picked</span>}
{t("Sketch:")} {chosen ? <span className="text-name">{chosen.name}</span> : <span className="text-muted-foreground">{t("none picked")}</span>}
</span>
<Button type="button" size="sm" variant={armed ? "default" : "outline"} className="h-6 px-2" data-testid="sketch-pick" aria-pressed={armed} title="Click a sketch in the viewport or the features list to use it" onClick={() => onArm(!armed)}>
<Crosshair /> {armed ? "picking…" : "pick in viewport"}
<Button type="button" size="sm" variant={armed ? "default" : "outline"} className="h-6 px-2" data-testid="sketch-pick" aria-pressed={armed} title={t("Click a sketch in the viewport or the features list to use it")} onClick={() => onArm(!armed)}>
<Crosshair /> {armed ? t("picking…") : t("pick in viewport")}
</Button>
</div>
<Select value={typeof raw === "string" ? raw : ""} onValueChange={onProfile}>
<SelectTrigger aria-invalid={invalid} aria-label="Sketch (list)">
<SelectValue placeholder="no sketch yet" />
<SelectTrigger aria-invalid={invalid} aria-label={t("Sketch (list)")}>
<SelectValue placeholder={t("no sketch yet")} />
</SelectTrigger>
<SelectContent>
{profiles.map((profile) => (
@@ -705,12 +706,12 @@ function SlotWidget({
</Select>
{chosen && (
<span className="text-[11px] text-muted-foreground">
Plane {profilePlaneLabel(chosen)}, normal <span className="text-name">{chosen.normal}</span>
{t("Plane {{plane}}, normal", { plane: profilePlaneLabel(chosen) })} <span className="text-name">{chosen.normal}</span>
</span>
)}
{summary && (
<span className="text-[11px] text-muted-foreground" data-testid="profile-summary">
This sketch has several loops; it uses what was chosen in the sketch ({summary}).
{t("This sketch has several loops; it uses what was chosen in the sketch ({{summary}}).", { summary })}
</span>
)}
</div>
@@ -747,24 +748,24 @@ function SlotWidget({
/>
);
case "select": {
const noun = slot.entity === "edge" ? "Edges" : "Faces";
const noun = slot.entity === "edge" ? t("Edges") : t("Faces");
const loading = filterSelection(selection, slot.entity ?? "face").some((item) => !isDescribed(item));
return (
<div className="flex flex-col gap-1 border-2 border-input px-2 py-1.5">
<span className="text-[12px]">
{kept ? (
<>
{noun}: <span className="text-muted-foreground">kept from the recipe</span>
{noun}: <span className="text-muted-foreground">{t("kept from the recipe")}</span>
</>
) : (
<>
{noun}: <span className="text-focus">{picks} picked</span>
{loading && <span className="text-muted-foreground"> (loading details…)</span>}
{noun}: <span className="text-focus">{t("{{count}} picked", { count: picks })}</span>
{loading && <span className="text-muted-foreground"> {t("(loading details…)")}</span>}
</>
)}
</span>
<span className="text-[11px] text-muted-foreground">
Pick {noun.toLowerCase()} in the viewport; Ctrl/Cmd+click adds.{kept ? " Pick again to replace them." : ""}
{slot.entity === "edge" ? t("Pick edges in the viewport; Ctrl/Cmd+click adds.") : t("Pick faces in the viewport; Ctrl/Cmd+click adds.")}{kept ? ` ${t("Pick again to replace them.")}` : ""}
</span>
</div>
);
+22 -21
View File
@@ -8,16 +8,17 @@ import { plainLabel } from "@/lib/commands";
import { candidateLabel, fetchRefStatus, refState, refTone, type Catalog, type FeatureRow, type FeatureState, type RefStatus, type Spec } from "@/lib/features";
import type { SketchInfo } from "@/lib/sketch-scene";
import { cn } from "@/lib/utils";
import { t } from "@/i18n";
/** Undo and redo with their counts. */
export function UndoRedo({ state, busy, onUndo, onRedo }: { state: Pick<FeatureState, "undo" | "redo">; busy?: boolean; onUndo: () => void; onRedo: () => void }) {
return (
<span className="flex items-center gap-1">
<Button type="button" size="sm" variant="outline" className="h-6 px-1.5" disabled={busy || state.undo === 0} title="Undo the last feature change (Ctrl/Cmd+Z)" onClick={onUndo}>
<Undo2 /> undo {state.undo > 0 && <span className="text-muted-foreground">{state.undo}</span>}
<Button type="button" size="sm" variant="outline" className="h-6 px-1.5" disabled={busy || state.undo === 0} title={t("Undo the last feature change (Ctrl/Cmd+Z)")} onClick={onUndo}>
<Undo2 /> {t("undo")} {state.undo > 0 && <span className="text-muted-foreground">{state.undo}</span>}
</Button>
<Button type="button" size="sm" variant="outline" className="h-6 px-1.5" disabled={busy || state.redo === 0} title="Redo (Ctrl/Cmd+Shift+Z)" onClick={onRedo}>
<Redo2 /> redo {state.redo > 0 && <span className="text-muted-foreground">{state.redo}</span>}
<Button type="button" size="sm" variant="outline" className="h-6 px-1.5" disabled={busy || state.redo === 0} title={t("Redo (Ctrl/Cmd+Shift+Z)")} onClick={onRedo}>
<Redo2 /> {t("redo")} {state.redo > 0 && <span className="text-muted-foreground">{state.redo}</span>}
</Button>
</span>
);
@@ -59,7 +60,7 @@ export function ReferenceHealth({ cell, version, busy, onRepair }: { cell: strin
);
return () => void (live = false);
}, [cell, version]);
if (failure) return <p className="mt-1 pl-[22px] text-[11px] text-muted-foreground">references: {failure}</p>;
if (failure) return <p className="mt-1 pl-[22px] text-[11px] text-muted-foreground">{t("references:")} {failure}</p>;
if (!status || status.badge === null) return null;
return (
<div className="mt-1 space-y-1 pl-[22px] text-[11px]" data-testid={`refs-${cell}`}>
@@ -74,7 +75,7 @@ export function ReferenceHealth({ cell, version, busy, onRepair }: { cell: strin
<div className="mt-0.5 flex flex-wrap gap-1">
{row.candidates.map((candidate, choice) => (
<Button key={choice} type="button" size="sm" variant="outline" className="h-6 px-1.5" disabled={busy}
title={state === "split" ? "Use this piece" : "Accept this look-alike"} onClick={() => onRepair(slot, index, choice)}>
title={state === "split" ? t("Use this piece") : t("Accept this look-alike")} onClick={() => onRepair(slot, index, choice)}>
{state === "split" ? `piece ${choice + 1}` : "use"}: {candidateLabel(candidate)}
</Button>
))}
@@ -140,23 +141,23 @@ export function FeatureTree({
return (
<div className="flex min-h-0 flex-1 flex-col">
<div className="flex items-center justify-between border-b border-border px-2 py-1.5">
<span className="label">features {state.features.length > 0 && `(${state.features.length})`}</span>
<span className="label">{t("features")} {state.features.length > 0 && `(${state.features.length})`}</span>
<UndoRedo state={state} busy={busy} onUndo={onUndo} onRedo={onRedo} />
</div>
{stale && state.tip && (
<div className="flex items-center gap-2 border-b-2 border-focus bg-accent px-3 py-1.5 text-[11px]">
<span className="min-w-0 flex-1">
The product still builds from <span className="text-name">{stale.body}</span>.
{t("The product still builds from")} <span className="text-name">{stale.body}</span>.
</span>
<Button type="button" size="sm" className="h-6 px-2" disabled={busy} onClick={() => onUseProduct(state.tip as string)}>
use {state.tip}
{t("use {{body}}", { body: state.tip })}
</Button>
</div>
)}
{error && <div className="border-b border-fail px-3 py-1 text-[11px] text-fail">{error}</div>}
<ScrollArea className="min-h-0 flex-1">
{state.features.length === 0 ? (
<p className="px-3 py-3 text-[11px] text-muted-foreground">No features yet. Add a Box or another operation above; each one becomes an ordinary cell in the notebook.</p>
<p className="px-3 py-3 text-[11px] text-muted-foreground">{t("No features yet. Add a Box or another operation from the command bar; each one becomes an ordinary cell in the notebook.")}</p>
) : (
<ul>
{state.features.map((feature) => {
@@ -188,14 +189,14 @@ export function FeatureTree({
<span className="w-5 shrink-0 text-[10px] text-muted-foreground">{feature.index}</span>
<span className="min-w-0 flex-1 truncate text-name">{feature.slug}</span>
{isProduct && (
<Badge variant="focus" title={state.product?.implicit ? "The part is this body (made by the runtime, no cell to keep)" : "The product cell builds from this body"}>
product
<Badge variant="focus" title={state.product?.implicit ? t("The part is this body (made by the runtime, no cell to keep)") : t("The product cell builds from this body")}>
{t("product")}
</Badge>
)}
<Badge variant="secondary">{feature.role}</Badge>
<Badge variant="secondary">{t(feature.role)}</Badge>
{sketch && sketch.usedBy.length > 0 && (
<Badge variant="secondary" title={`Used by ${sketch.usedBy.join(", ")}: drawn dimmer in the viewport`}>
used
<Badge variant="secondary" title={t("Used by {{users}}: drawn dimmer in the viewport", { users: sketch.usedBy.join(", ") })}>
{t("used")}
</Badge>
)}
<Badge variant={feature.gui ? "outline" : "name"}>{spec ? plainLabel(spec.id, spec.label) : feature.gui ? feature.gui.spec.replace(/_/g, " ") : "code"}</Badge>
@@ -212,15 +213,15 @@ export function FeatureTree({
className="h-6 w-6"
data-testid={`sketch-eye-${sketch.name}`}
aria-pressed={!hiddenSketch}
aria-label={hiddenSketch ? `show ${sketch.name} in the viewport` : `hide ${sketch.name} in the viewport`}
title={hiddenSketch ? "Show this sketch in the viewport" : "Hide this sketch in the viewport"}
aria-label={hiddenSketch ? t("show {{name}} in the viewport", { name: sketch.name }) : t("hide {{name}} in the viewport", { name: sketch.name })}
title={hiddenSketch ? t("Show this sketch in the viewport") : t("Hide this sketch in the viewport")}
onClick={() => sketches?.onToggleHidden(sketch.name)}
>
{hiddenSketch ? <EyeOff className="text-muted-foreground" /> : <Eye />}
</Button>
)}
<span title={canEdit ? "Edit this feature" : "Written as code: edit it in the notebook"}>
<Button type="button" size="icon" variant="ghost" className="h-6 w-6" disabled={!canEdit || busy} aria-label={`edit ${feature.slug}`} onClick={() => spec && onEdit(feature, spec)}>
<span title={canEdit ? t("Edit this feature") : t("Written as code: edit it in the notebook")}>
<Button type="button" size="icon" variant="ghost" className="h-6 w-6" disabled={!canEdit || busy} aria-label={t("edit {{name}}", { name: feature.slug })} onClick={() => spec && onEdit(feature, spec)}>
<Pencil />
</Button>
</span>
@@ -230,8 +231,8 @@ export function FeatureTree({
variant={armed === feature.cell ? "destructive" : "ghost"}
className="h-6 w-6"
disabled={busy}
aria-label={armed === feature.cell ? `confirm delete ${feature.slug}` : `delete ${feature.slug}`}
title={armed === feature.cell ? "Click again to delete" : "Delete this feature"}
aria-label={armed === feature.cell ? t("confirm delete {{name}}", { name: feature.slug }) : t("delete {{name}}", { name: feature.slug })}
title={armed === feature.cell ? t("Click again to delete") : t("Delete this feature")}
onClick={() => {
if (armed === feature.cell) {
setArmed(null);
+9 -8
View File
@@ -2,6 +2,7 @@ import { useState, type ReactNode } from "react";
import { ChevronsLeft, ChevronsRight, ListTree, ScanSearch } from "lucide-react";
import { cn } from "@/lib/utils";
import { t } from "@/i18n";
/** Whether a card is open, remembered in this browser (a convenience: it reads as open when storage is unavailable). */
function useRemembered(key: string): [boolean, (open: boolean) => void] {
@@ -66,17 +67,17 @@ export function FloatingPanels({
<button
type="button"
className="absolute right-0 top-0 z-10 flex h-9 w-8 items-center justify-center border-l-2 border-border bg-popover text-muted-foreground hover:text-foreground"
aria-label="Collapse the panel"
title="Collapse the panel"
aria-label={t("Collapse the panel")}
title={t("Collapse the panel")}
onClick={() => setBrowserOpen(false)}
>
<ChevronsLeft className="size-3.5" />
</button>
</div>
) : (
<button type="button" className={PILL} onClick={() => setBrowserOpen(true)} aria-label="Open the panel">
<button type="button" className={PILL} onClick={() => setBrowserOpen(true)} aria-label={t("Open the panel")}>
<ListTree className="size-3.5" />
panel
{t("panel")}
</button>
)}
{leftNotice && <div className="w-full min-h-0 shrink">{leftNotice}</div>}
@@ -89,17 +90,17 @@ export function FloatingPanels({
<button
type="button"
className="absolute right-0 top-0 z-10 flex h-9 w-8 items-center justify-center border-l-2 border-border bg-popover text-muted-foreground hover:text-foreground"
aria-label="Collapse the inspector"
title="Collapse the inspector"
aria-label={t("Collapse the inspector")}
title={t("Collapse the inspector")}
onClick={() => setInspectorOpen(false)}
>
<ChevronsRight className="size-3.5" />
</button>
</div>
) : (
<button type="button" className={PILL} onClick={() => setInspectorOpen(true)} aria-label="Open the inspector">
<button type="button" className={PILL} onClick={() => setInspectorOpen(true)} aria-label={t("Open the inspector")}>
<ScanSearch className="size-3.5" />
inspector{selectionCount > 0 ? ` · ${selectionCount}` : ""}
{t("inspector")}{selectionCount > 0 ? ` · ${selectionCount}` : ""}
</button>
)}
{rightNotice && <div className="w-full">{rightNotice}</div>}
+23 -10
View File
@@ -1,4 +1,4 @@
import { Monitor, Moon, Play, Square, Sun } from "lucide-react";
import { Languages, Monitor, Moon, Play, Square, Sun } from "lucide-react";
import type { ThemePreference } from "@/lib/theme";
@@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button";
import { UndoRedo } from "@/components/FeatureTree";
import { ModeSwitch, type EditorMode } from "@/components/ModeSwitch";
import type { FeatureState } from "@/lib/features";
import { LANGUAGES, setLanguage, useI18n } from "@/i18n";
/** Top bar: which notebook is open, whether its kernel is alive, and the
* model's last message. Everything else lives on the cells. */
@@ -45,7 +46,9 @@ export function Header({
/** A sketch is open or the panels are moving: the mode cannot change now. */
modeLocked: boolean;
}) {
const { t, language } = useI18n();
const failing = status.startsWith("error");
const nextLanguage = LANGUAGES[(LANGUAGES.findIndex((item) => item.code === language) + 1) % LANGUAGES.length];
return (
<header className="flex h-11 shrink-0 items-center gap-3 border-b-2 border-border bg-background px-3">
<span className="text-[13px] font-bold uppercase tracking-[0.14em]">SimpleCAD</span>
@@ -56,11 +59,11 @@ export function Header({
{kind && kind !== "helper" && <Badge variant="outline">{kind}</Badge>}
</span>
) : (
<span className="text-muted-foreground">no notebook</span>
<span className="text-muted-foreground">{t("no notebook")}</span>
)}
<span
className={`inline-block h-2 w-2 ${kernelAlive ? "bg-pass" : "bg-fail"}`}
title={kernelAlive ? "kernel running" : "kernel stopped"}
title={kernelAlive ? t("kernel running") : t("kernel stopped")}
/>
<span
className={`min-w-0 flex-1 truncate text-[11px] ${failing ? "text-fail" : "text-muted-foreground"}`}
@@ -70,23 +73,33 @@ export function Header({
</span>
<UndoRedo state={features} onUndo={onUndo} onRedo={onRedo} />
{running ? (
<Button size="sm" variant="destructive" onClick={onStop} title="Stop the run (interrupt the kernel)">
<Square className="fill-current" /> stop
<Button size="sm" variant="destructive" onClick={onStop} title={t("Stop the run (interrupt the kernel)")}>
<Square className="fill-current" /> {t("stop")}
</Button>
) : (
<Button size="sm" variant="outline" onClick={onRunAll} title="Run every cell">
<Play /> run all
<Button size="sm" variant="outline" onClick={onRunAll} title={t("Run every cell")}>
<Play /> {t("run all")}
</Button>
)}
<Button
size="sm"
variant="ghost"
onClick={onTheme}
title={`Theme: ${themePreference} (click: ${NEXT_THEME[themePreference]})`}
aria-label={`Theme: ${themePreference}. Switch to ${NEXT_THEME[themePreference]}`}
title={t("Theme: {{theme}} (click: {{next}})", { theme: t(themePreference), next: t(NEXT_THEME[themePreference]) })}
aria-label={t("Theme: {{theme}}. Switch to {{next}}", { theme: t(themePreference), next: t(NEXT_THEME[themePreference]) })}
>
{themePreference === "system" ? <Monitor /> : themePreference === "light" ? <Sun /> : <Moon />}
{themePreference}
{t(themePreference)}
</Button>
<Button
size="sm"
variant="ghost"
onClick={() => setLanguage(nextLanguage.code)}
title={t("Language (click: {{next}})", { next: nextLanguage.label })}
aria-label={t("Language (click: {{next}})", { next: nextLanguage.label })}
>
<Languages />
{LANGUAGES.find((item) => item.code === language)?.label ?? "EN"}
</Button>
<ModeSwitch mode={mode} onChange={onMode} disabled={modeLocked} />
</header>
+10 -10
View File
@@ -2,6 +2,7 @@ import { Badge } from "@/components/ui/badge";
import { ScrollArea } from "@/components/ui/scroll-area";
import { JsonTree } from "@/components/JsonTree";
import type { SelectionItem } from "@/lib/selection";
import { t } from "@/i18n";
/** Right-hand inspector: what is selected in the viewport, each item with
* the variable the selection cell assigns it to and its data as a tree. */
@@ -10,14 +11,13 @@ export function Inspector({ selection, sketches = [] }: { selection: SelectionIt
return (
<div className="flex h-full flex-col">
<div className="flex h-9 shrink-0 items-center justify-between border-b-2 border-border pl-3 pr-10">
<span className="label text-foreground">selection</span>
<span className="label text-foreground">{t("selection")}</span>
{count > 0 && <span className="label">{count}</span>}
</div>
<ScrollArea className="min-h-0 flex-1">
{count === 0 ? (
<p className="p-3 text-[11px] text-muted-foreground">
Click a solid, face, edge, vertex or sketch in the viewport (pick the kind with the chips above it).
Ctrl/Cmd+click adds to the selection; picked model items are written to the notebook as{" "}
{t("Click a solid, face, edge, vertex or sketch in the viewport (pick the kind with the chips). Ctrl/Cmd+click adds to the selection; picked model items are written to the notebook as")}{" "}
<span className="text-name">selected_item</span>.
</p>
) : (
@@ -46,16 +46,16 @@ export function Inspector({ selection, sketches = [] }: { selection: SelectionIt
</span>
</div>
<dl className="space-y-0.5 px-3 pb-2 text-[11px]">
<Line label="entity" value={item.entityId ?? "—"} />
<Line label="node" value={item.nodeId} />
{item.definitionId && <Line label="definition" value={item.definitionId} />}
<Line label={t("entity")} value={item.entityId ?? "—"} />
<Line label={t("node")} value={item.nodeId} />
{item.definitionId && <Line label={t("definition")} value={item.definitionId} />}
</dl>
{item.pending && <p className="label px-3 pb-2">loading details…</p>}
{item.pending && <p className="label px-3 pb-2">{t("loading details…")}</p>}
{(item.properties || item.geometry) && (
<div className="space-y-2 border-t border-border px-3 py-2">
{item.properties && <Group title="properties" value={item.properties} />}
{item.geometry && <Group title="geometry" value={item.geometry} />}
{item.tags && item.tags.length > 0 && <Group title="tags" value={item.tags} />}
{item.properties && <Group title={t("properties")} value={item.properties} />}
{item.geometry && <Group title={t("geometry")} value={item.geometry} />}
{item.tags && item.tags.length > 0 && <Group title={t("tags")} value={item.tags} />}
</div>
)}
</li>
+2 -1
View File
@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from "react";
import { cn } from "@/lib/utils";
import { t } from "@/i18n";
/** Cells of the 3x3 spinner that form its ring, clockwise from the top left. */
const RING = [0, 1, 2, 5, 8, 7, 6, 3];
@@ -50,7 +51,7 @@ export function LoadingMask({ active, message, theme }: { active: boolean; messa
<Ripple theme={theme} />
<div className="relative w-[280px] border-2 border-foreground/80 bg-background shadow-[6px_6px_0_0_var(--shadow-hard)]">
<div className="flex h-6 items-center justify-between bg-foreground/85 px-2 text-[11px] font-bold uppercase tracking-[0.18em] text-background">
<span>loading</span>
<span>{t("loading")}</span>
<span className="tabular-nums">
{minutes}:{seconds}
</span>
+4 -3
View File
@@ -1,4 +1,5 @@
import { cn } from "@/lib/utils";
import { t } from "@/i18n";
export type EditorMode = "manual" | "code";
@@ -10,7 +11,7 @@ const OPTIONS: { value: EditorMode; label: string; hint: string }[] = [
/** The big two-position switch of the top bar: manual mode on the left, code mode on the right. */
export function ModeSwitch({ mode, onChange, disabled }: { mode: EditorMode; onChange: (mode: EditorMode) => void; disabled?: boolean }) {
return (
<div role="radiogroup" aria-label="Editor mode" data-testid="mode-switch" className={cn("relative grid h-8 grid-cols-2 border-2 border-primary", disabled && "opacity-50")}>
<div role="radiogroup" aria-label={t("Editor mode")} data-testid="mode-switch" className={cn("relative grid h-8 grid-cols-2 border-2 border-primary", disabled && "opacity-50")}>
<span
aria-hidden
className="pointer-events-none absolute inset-y-0 left-0 w-1/2 bg-primary transition-transform duration-300 ease-[cubic-bezier(0.2,0.8,0.2,1)]"
@@ -22,7 +23,7 @@ export function ModeSwitch({ mode, onChange, disabled }: { mode: EditorMode; onC
type="button"
role="radio"
aria-checked={mode === option.value}
title={option.hint}
title={t(option.hint)}
disabled={disabled}
data-mode={option.value}
onClick={() => option.value !== mode && onChange(option.value)}
@@ -31,7 +32,7 @@ export function ModeSwitch({ mode, onChange, disabled }: { mode: EditorMode; onC
mode === option.value ? "text-primary-foreground" : "text-muted-foreground hover:text-foreground",
)}
>
{option.label}
{t(option.label)}
</button>
))}
</div>
+3 -2
View File
@@ -10,6 +10,7 @@ import { ParamControl, type ParamMeta, type ParamValue } from "@/components/Para
import { cadTheme } from "@/lib/cm-theme";
import { createSettler, SETTLE_MS } from "@/lib/settle";
import { sdkCompletion } from "@/lib/sdk-complete";
import { t } from "@/i18n";
/** A local module of the workspace (shared dimensions, helpers): what the
* server sends as the `module` envelope. */
@@ -103,12 +104,12 @@ export function ModuleView({
used by {module.used_by.map((path) => path.replace(/\.py$/, "")).join(", ")}
</span>
) : (
<Badge variant="secondary">unused</Badge>
<Badge variant="secondary">{t("unused")}</Badge>
)}
<button
type="button"
className="flex h-6 w-6 items-center justify-center border-2 border-transparent text-muted-foreground hover:border-input hover:text-foreground"
title="Close the module view"
title={t("Close the module view")}
onClick={onClose}
>
<X className="h-3.5 w-3.5" />
@@ -1,5 +1,6 @@
import { useState } from "react";
import { FilePlus2, X } from "lucide-react";
import { t } from "@/i18n";
/** Shown over the viewport when an operation or a drawing is started with no notebook open: everything the editor does
* is written into a notebook, so one has to exist first. Creates it here (a part, empty) or sends the person away. */
@@ -23,18 +24,18 @@ export function NewNotebookPrompt({ onCreate, onClose }: { onCreate: (name: stri
<div className="pointer-events-auto absolute inset-0 z-30 flex items-center justify-center bg-background/40" onClick={onClose}>
<div
role="dialog"
aria-label="Create a notebook first"
aria-label={t("Create a notebook first")}
className="flex w-[min(380px,90%)] flex-col gap-3 border-2 border-[var(--focus)] bg-popover p-4 text-xs shadow-[4px_4px_0_var(--shadow-hard)]"
onClick={(event) => event.stopPropagation()}
>
<div className="flex items-center gap-2 font-semibold">
<FilePlus2 className="size-4 text-[var(--focus)]" />
<span className="flex-1">No notebook is open</span>
<button type="button" aria-label="Close" className="hover:text-foreground text-muted-foreground" onClick={onClose}>
<span className="flex-1">{t("No notebook is open")}</span>
<button type="button" aria-label={t("Close")} className="hover:text-foreground text-muted-foreground" onClick={onClose}>
<X className="size-3.5" />
</button>
</div>
<p className="text-muted-foreground">Every operation and drawing is written into a notebook. Create one first (it starts empty).</p>
<p className="text-muted-foreground">{t("Every operation and drawing is written into a notebook. Create one first (it starts empty).")}</p>
<form
className="flex gap-2"
onSubmit={(event) => {
@@ -47,10 +48,10 @@ export function NewNotebookPrompt({ onCreate, onClose }: { onCreate: (name: stri
value={name}
onChange={(event) => setName(event.target.value)}
className="min-w-0 flex-1 border border-border bg-background px-2 py-1 font-mono"
aria-label="Notebook name"
aria-label={t("Notebook name")}
/>
<button type="submit" disabled={busy || !name.trim()} className="border-2 border-foreground bg-foreground px-3 py-1 font-semibold text-background disabled:opacity-50">
Create
{t("create")}
</button>
</form>
{error && <p className="text-destructive">{error}</p>}
+20 -19
View File
@@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
import { cn } from "@/lib/utils";
import type { ModuleRow, NotebookRow } from "@/lib/api";
import { t } from "@/i18n";
/** Names the template accepts: the notebook's id and its file name. */
const NAME = /^[A-Za-z_][A-Za-z0-9_-]*$/;
@@ -43,14 +44,14 @@ export function NotebookList({
return (
<ScrollArea className="h-full">
<div className="flex items-center justify-between border-b border-border px-3 py-1.5">
<span className="label">notebooks</span>
<span className="label">{t("notebooks")}</span>
<button
type="button"
className="label flex items-center gap-1 hover:text-foreground"
title="Start a new notebook from the template"
title={t("Start a new, empty notebook")}
onClick={() => setAdding((open) => !open)}
>
<Plus className="h-3 w-3" /> new
<Plus className="h-3 w-3" /> {t("new")}
</button>
</div>
{(adding || empty) && (
@@ -63,7 +64,7 @@ export function NotebookList({
<button
type="button"
className="absolute right-2 top-2 z-10 hidden p-1 text-muted-foreground hover:text-fail group-hover:block"
title={`Delete ${row.name} (kept in .sca-editor/trash)`}
title={t("Delete {{name}} (kept in .sca-editor/trash)", { name: row.name })}
aria-label={`delete ${row.name}`}
onClick={() => {
setDeleteError(null);
@@ -86,10 +87,10 @@ export function NotebookList({
onDelete?.(row.path).catch((error) => setDeleteError({ path: row.path, text: error instanceof Error ? error.message : String(error) }));
}}
>
delete
{t("delete")}
</button>
<button type="button" className="border border-border px-1.5 hover:bg-background" onClick={() => setConfirming(null)}>
keep
{t("keep")}
</button>
</div>
)}
@@ -110,7 +111,7 @@ export function NotebookList({
<span className="flex items-center gap-2">
<span className={row.path === current ? "text-focus" : "text-foreground"}>{row.name}</span>
<Badge variant="secondary">{row.kind}</Badge>
{row.error && <Badge variant="fail">error</Badge>}
{row.error && <Badge variant="fail">{t("error")}</Badge>}
</span>
{row.uses && row.uses.length > 0 && (
<span className="truncate text-[10px] text-muted-foreground">
@@ -138,7 +139,7 @@ export function NotebookList({
>
<span className={openModule === module.path ? "text-name" : "text-foreground"}>{module.path}</span>
<span className="truncate text-[10px] text-muted-foreground">
used by {module.used_by.map((path) => path.replace(/\.py$/, "")).join(", ")}
{t("used by {{users}}", { users: module.used_by.map((path) => path.replace(/\.py$/, "")).join(", ") })}
</span>
</button>
</li>
@@ -175,15 +176,15 @@ function NewEntry({
const submit = async () => {
const value = name.trim();
if (!NAME.test(value)) return setError("Use letters, digits, - and _, starting with a letter or _.");
if (taken(value)) return setError(`${value}.py already exists.`);
if (!NAME.test(value)) return setError(t("Use letters, digits, - and _, starting with a letter or _."));
if (taken(value)) return setError(t("{{name}}.py already exists.", { name: value }));
setBusy(true);
setError(null);
try {
await onCreate(value, kind);
onDone();
} catch (reason) {
setError(reason instanceof Error ? reason.message : "Could not create the notebook.");
setError(reason instanceof Error ? reason.message : t("Could not create the notebook."));
} finally {
setBusy(false);
}
@@ -197,7 +198,7 @@ function NewEntry({
void submit();
}}
>
{first && <p className="text-[11px] text-muted-foreground">An empty workspace. Start with a part: a notebook that builds one solid.</p>}
{first && <p className="text-[11px] text-muted-foreground">{t("An empty workspace. Start with a part: a notebook that builds one solid.")}</p>}
<input
ref={input}
autoFocus
@@ -207,8 +208,8 @@ function NewEntry({
setError(null);
}}
onKeyDown={(event) => event.key === "Escape" && !first && onCancel()}
placeholder="name, e.g. bracket"
aria-label="Name of the new notebook"
placeholder={t("name, e.g. bracket")}
aria-label={t("Name of the new notebook")}
spellCheck={false}
className="w-full border-2 border-input bg-transparent px-2 py-1 focus:border-focus focus:outline-none"
/>
@@ -218,7 +219,7 @@ function NewEntry({
key={option}
type="button"
disabled={option === "assembly" && parts.length === 0}
title={option === "assembly" && parts.length === 0 ? "An assembly puts parts together: create a part first" : undefined}
title={option === "assembly" && parts.length === 0 ? t("An assembly puts parts together: create a part first") : undefined}
onClick={() => {
setKind(option);
input.current?.focus(); // Enter then creates
@@ -228,23 +229,23 @@ function NewEntry({
kind === option ? "border-primary bg-primary text-primary-foreground" : "border-transparent text-muted-foreground hover:border-input hover:text-foreground",
)}
>
{option}
{t(option)}
</button>
))}
</div>
{kind === "assembly" && parts.length > 0 && (
<p className="text-[11px] text-muted-foreground">
Starts with {parts.slice(0, 2).map((row) => row.name).join(" and ")}; change what it uses in its cells.
{t("Starts with {{parts}}; change what it uses in its cells.", { parts: parts.slice(0, 2).map((row) => row.name).join(", ") })}
</p>
)}
{error && <p className="text-[11px] text-fail">{error}</p>}
<div className="flex gap-2">
<Button size="sm" type="submit" disabled={busy || !name.trim()}>
create
{t("create")}
</Button>
{!first && (
<Button size="sm" type="button" variant="ghost" onClick={onCancel}>
cancel
{t("cancel")}
</Button>
)}
</div>
@@ -3,6 +3,7 @@ import { useRef } from "react";
import { cn } from "@/lib/utils";
import { isEnabled, moveIndex, type SegmentOption } from "@/lib/segmented";
import { t } from "@/i18n";
/** A segmented control: one of a few short choices, always visible (a radio group, not a dropdown).
*
@@ -71,7 +72,7 @@ export function OperationChooser({
aria-checked={on}
disabled={Boolean(option.disabled)}
tabIndex={index === tabbable ? 0 : -1}
title={reason ?? option.hint}
title={reason ? t(reason) : option.hint && t(option.hint)}
data-testid={`${testId}-${option.value}`}
className={cn(
"flex flex-1 items-center justify-center gap-1 px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-40",
@@ -82,14 +83,14 @@ export function OperationChooser({
onKeyDown={(event) => onKeyDown(event, index)}
>
{Icon && <Icon className="size-3.5 shrink-0" aria-hidden />}
{option.label}
{t(option.label)}
</button>
);
})}
</div>
{(note || hint) && (
<span className="text-[11px] text-muted-foreground" data-testid={`${testId}-hint`}>
{note ?? `${options[selected]?.label ?? ""} ${hint}.`}
{note ? t(note) : `${t(options[selected]?.label ?? "")} ${hint ? t(hint) : ""}.`}
</span>
)}
</div>
+2 -1
View File
@@ -2,6 +2,7 @@ import { useMemo } from "react";
import { TriangleAlert } from "lucide-react";
import { describePartial, type PartialModel } from "@/lib/partial";
import { t } from "@/i18n";
/** Says that the model in the viewport is the one before a failing step (a cell failed, so the product was not made): which
* step failed and why, and that the steps after it did not run. It stays while the model is partial and goes when the
@@ -22,7 +23,7 @@ export function PartialNotice({ partial, titles, docked = false }: { partial: Pa
<span>{title}</span>
</div>
<span className="line-clamp-2 text-fail">{reason}</span>
<span className="text-muted-foreground">{after ? `${after}; the` : "The"} whole model comes back once it is fixed.</span>
<span className="text-muted-foreground">{after ? `${after}; ` : ""}{t("the whole model comes back once it is fixed.")}</span>
</div>
);
}
+5 -4
View File
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from "react";
import { Scissors } from "lucide-react";
import type { SceneView } from "@/scene/scene-view";
import { t } from "@/i18n";
/** A tagged entity an operation split (the server's `tag_splits`, from `scad.list_tag_splits`): the pieces carry
* `<tag>.split<i>`, and `pieces` lists the scene entities of each. */
@@ -50,13 +51,13 @@ export function TagSplits({ view, splits, sceneVersion, docked = false }: { view
<div className={`pointer-events-auto ${docked ? "relative min-h-0 max-h-[360px]" : "absolute left-3 top-3 z-20 max-h-[min(50%,360px)] max-w-[min(420px,80%)]"} flex flex-col gap-1.5 border-2 border-[var(--focus)] bg-popover px-3 py-2 text-[11px] shadow-[4px_4px_0_var(--shadow-hard)]`} data-testid="tag-splits">
<div className="flex items-center gap-2 font-semibold">
<Scissors className="size-3.5 text-[var(--focus)]" />
<span>{splits.length === 1 ? "A tagged entity was split" : `${splits.length} tagged entities were split`}</span>
<span>{splits.length === 1 ? t("A tagged entity was split") : t("{{count}} tagged entities were split", { count: splits.length })}</span>
</div>
<div className="flex min-h-0 flex-col gap-1.5 overflow-y-auto pr-1">
{splits.map((row) => (
<div key={`${row.op}:${row.tag}:${row.into.join(",")}`} className="flex flex-col gap-1">
<span className="text-muted-foreground">
<span className="font-mono text-foreground">{row.op}</span> split <span className="font-mono text-foreground">{row.tag}</span> into {row.into.length}; the tag names none of them:
{t("{{op}} split {{tag}} into {{count}}; the tag names none of them:", { op: row.op, tag: row.tag, count: row.into.length })}
</span>
<span className="flex flex-wrap gap-1">
{row.into.map((name, index) => (
@@ -71,10 +72,10 @@ export function TagSplits({ view, splits, sceneVersion, docked = false }: { view
</div>
<div className="flex shrink-0 gap-2 pt-0.5">
<button type="button" className="border border-border px-2 py-0.5 hover:bg-accent" onClick={() => setShown((value) => !value)}>
{shown ? "Hide highlight" : "Show highlight"}
{shown ? t("Hide highlight") : t("Show highlight")}
</button>
<button type="button" className="border border-border px-2 py-0.5 hover:bg-accent" onClick={() => setDismissed(signature)}>
Dismiss
{t("Dismiss")}
</button>
</div>
</div>
+13 -12
View File
@@ -8,6 +8,7 @@ import { placeValues, placedFrame, type PlaceFrame, type PlaceValues } from "@/l
import { OVERLAY_LAYER } from "@/scene/renderer/brep-renderer";
import type { SceneView } from "@/scene/scene-view";
import type { Vec3 } from "@/lib/sketch-plane";
import { t } from "@/i18n";
export type PlaceMode = "translate" | "rotate";
@@ -212,16 +213,16 @@ export function WorkplanePlacePanel({
return (
<div className="pointer-events-auto absolute left-3 top-3 z-30 flex max-w-[min(440px,90%)] flex-col gap-2 border-2 border-primary bg-popover px-3 py-2 text-[11px] shadow-[4px_4px_0_var(--shadow-hard)]" data-testid={title === "Workplane" ? "workplane-placer" : `${title.toLowerCase()}-placer`}>
<div className="scroll-row items-center gap-2">
<span className="font-semibold">{title}</span>
<span className="font-semibold">{t(title)}</span>
<input
id="workplane-place-name"
aria-label="name"
aria-label={t("name")}
className="w-20 border border-input bg-background px-1 font-mono"
value={name}
onChange={(event) => onName(event.target.value)}
/>
<span className="text-muted-foreground">on</span>
<select id="workplane-place-base" aria-label="base" className="border border-input bg-background px-1" value={base} onChange={(event) => onBase(event.target.value)}>
<span className="text-muted-foreground">{t("on")}</span>
<select id="workplane-place-base" aria-label={t("base")} className="border border-input bg-background px-1" value={base} onChange={(event) => onBase(event.target.value)}>
{bases.map((item) => (
<option key={item.value} value={item.value}>
{item.label}
@@ -229,18 +230,18 @@ export function WorkplanePlacePanel({
))}
</select>
<span className="flex border border-input">
<button type="button" title="Move (G)" className={`flex items-center gap-1 px-1.5 ${mode === "translate" ? "bg-primary text-primary-foreground" : ""}`} onClick={() => onMode("translate")}>
<Move3d className="size-3" /> move
<button type="button" title={t("Move (G)")} className={`flex items-center gap-1 px-1.5 ${mode === "translate" ? "bg-primary text-primary-foreground" : ""}`} onClick={() => onMode("translate")}>
<Move3d className="size-3" /> {t("move")}
</button>
<button type="button" title="Turn (R)" className={`flex items-center gap-1 px-1.5 ${mode === "rotate" ? "bg-primary text-primary-foreground" : ""}`} onClick={() => onMode("rotate")}>
<RotateCw className="size-3" /> turn
<button type="button" title={t("Turn (R)")} className={`flex items-center gap-1 px-1.5 ${mode === "rotate" ? "bg-primary text-primary-foreground" : ""}`} onClick={() => onMode("rotate")}>
<RotateCw className="size-3" /> {t("turn")}
</button>
</span>
</div>
<div className="scroll-row items-center gap-1.5">
{fields.map((field) => (
<label key={field.key} className="flex items-center gap-0.5">
<span className="text-muted-foreground">{field.label}</span>
<span className="text-muted-foreground">{t(field.label)}</span>
<input
id={`workplane-place-${field.key}`}
className="w-14 border border-input bg-background px-1 text-right font-mono tabular-nums"
@@ -259,12 +260,12 @@ export function WorkplanePlacePanel({
</div>
<div className="flex items-center gap-2">
<button type="button" disabled={busy} className="border-2 border-primary bg-primary px-2 py-0.5 font-semibold text-primary-foreground disabled:opacity-50" onClick={onCreate}>
{createLabel} (Enter)
{t(createLabel)} (Enter)
</button>
<button type="button" className="border border-border px-2 py-0.5 hover:bg-accent" onClick={onCancel}>
Cancel (Esc)
{t("Cancel")} (Esc)
</button>
<span className="text-muted-foreground">drag the arrows to move, the rings to turn · Shift: no snapping</span>
<span className="text-muted-foreground">{t("drag the arrows to move, the rings to turn · Shift: no snapping")}</span>
</div>
{error && (
<div role="alert" className="text-fail">
+43
View File
@@ -0,0 +1,43 @@
import { readdirSync, readFileSync, statSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import zhCN from "./locales/zh-CN.json";
const SRC = join(import.meta.dirname, "..");
function sources(dir: string): string[] {
return readdirSync(dir).flatMap((name) => {
const path = join(dir, name);
if (statSync(path).isDirectory()) return sources(path);
return /\.tsx?$/.test(name) && !/\.test\.tsx?$/.test(name) ? [path] : [];
});
}
/** Every literal key of the source: t("…") and t('…'), also as tt(…) (a t passed down under another name). */
function keys(): Map<string, string> {
const found = new Map<string, string>();
const call = /\bt{1,2}\(\s*("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/g;
for (const path of sources(SRC)) {
const text = readFileSync(path, "utf8");
for (const match of text.matchAll(call)) found.set(JSON.parse(match[1].startsWith("'") ? `"${match[1].slice(1, -1).replace(/"/g, '\\"')}"` : match[1]), path);
}
return found;
}
describe("translations", () => {
const table = zhCN as Record<string, string>;
it("has a Chinese entry for every key the source uses", () => {
const missing = [...keys()].filter(([key]) => !(key in table)).map(([key, path]) => `${path.slice(SRC.length + 1)}: ${key}`);
expect(missing).toEqual([]);
});
it("keeps every interpolation of a key in its translation", () => {
const broken = Object.entries(table).filter(([key, value]) => {
const names = (text: string) => [...text.matchAll(/\{\{\s*(\w+)\s*\}\}/g)].map((m) => m[1]).sort().join(",");
return names(key) !== names(value);
});
expect(broken).toEqual([]);
});
});
+63
View File
@@ -0,0 +1,63 @@
/** The editor's languages. The English text is the key: `t("Collapse the panel")` reads as what it shows, English
* needs no table, and a missing translation shows the English. `locales/zh-CN.json` maps English to Chinese; the
* coverage test (i18n.test.ts) fails when a literal key passed to t in the source has no entry there.
*
* Not translated: SDK names (operations, parameters, entity ids), code, cell titles, and what the server says
* verbatim (an error of the kernel). */
import i18n from "i18next";
import { initReactI18next, useTranslation } from "react-i18next";
import zhCN from "./locales/zh-CN.json";
export const LANGUAGES = [
{ code: "en", label: "EN" },
{ code: "zh-CN", label: "中" },
] as const;
export type Language = (typeof LANGUAGES)[number]["code"];
const STORE_KEY = "sca.language";
/** The saved choice, else the browser's language (Chinese for any zh-*, English otherwise). */
export function initialLanguage(): Language {
try {
const saved = window.localStorage.getItem(STORE_KEY);
if (saved === "en" || saved === "zh-CN") return saved;
} catch {
// storage blocked: follow the browser
}
const preferred = typeof navigator !== "undefined" ? navigator.languages ?? [navigator.language] : [];
return preferred.some((tag) => tag?.toLowerCase().startsWith("zh")) ? "zh-CN" : "en";
}
void i18n.use(initReactI18next).init({
lng: typeof window === "undefined" ? "en" : initialLanguage(),
fallbackLng: "en",
resources: { "zh-CN": { translation: zhCN } },
// English sentences are keys: they contain dots and colons
keySeparator: false,
nsSeparator: false,
interpolation: { escapeValue: false }, // React escapes
returnEmptyString: false,
});
export function setLanguage(language: Language): void {
void i18n.changeLanguage(language);
document.documentElement.lang = language;
try {
window.localStorage.setItem(STORE_KEY, language);
} catch {
// storage blocked: the choice lasts until the page reloads
}
}
/** `t` and the current language, re-rendering on a change. */
export function useI18n() {
const { t, i18n: instance } = useTranslation();
return { t, language: (instance.resolvedLanguage ?? instance.language) as Language };
}
/** Outside React (a message built in a library function): the current language at the time of the call. */
export const t = (key: string, options?: Record<string, unknown>): string => i18n.t(key, options) as string;
export default i18n;
+854
View File
@@ -0,0 +1,854 @@
{
"#{{n}}: click to leave it out": "第 {{n}} 个:点击移除",
"(loading details…)": "(正在加载详情…)",
"/ or Ctrl+K": "/ 或 Ctrl+K",
"1 cell": "1 个单元",
"1 cell re-evaluated in {{time}}": "1 个单元重新计算,用时 {{time}}",
"1 error": "1 个错误",
"1 later step did not run": "后面有 1 个步骤没有运行",
"1 segment": "1 段",
"2d cut": "二维差集",
"2d intersect": "二维交集",
"2d union": "二维并集",
"3D curve": "3D 曲线",
"A cone, or a frustum when the top radius is above zero.": "圆锥;顶面半径大于零时为圆台。",
"A connector is placed on one flat face: pick it first (face mode).": "连接器放在一个平面上:请先选中它(面选择模式)。",
"A constrained 2D sketch on a plane, made into a face (a closed profile) or a wire (a profile or an open path).": "平面上带约束的二维草图,可生成面(闭合轮廓)或线框(轮廓或开放路径)。",
"A cylinder standing on a centre point, along an axis.": "立在中心点上、沿某个轴方向的圆柱。",
"A face parallel to the first.": "与第一个面平行的面。",
"A feature keeps its name.": "特征名称创建后不可更改。",
"A part holds one solid: this one starts the part.": "一个零件只有一个实体:这个实体是零件的起点。",
"A path in space: lines, arcs and splines through points in space, on workplanes or at vertices of the model, joined into one wire (a sweep path, a rail). Drawn in the viewport with snapping.": "空间中的路径:由经过空间点、工作平面上的点或模型顶点的直线、圆弧和样条连接成一条线框(可作扫掠路径或导轨)。在视口中带吸附绘制。",
"A planar face (for an axis: the face the plane starts from).": "一个平面(对于轴:平面起始的那个面)。",
"A rectangular block; its bottom face is centred on the origin point.": "长方体,底面中心位于原点。",
"A round hole from a point on a surface, in a direction, to a depth.": "从表面上一点沿某方向打到指定深度的圆孔。",
"A sketch made earlier.": "之前画好的草图。",
"A sphere around a centre point.": "以中心点为球心的球体。",
"A tagged entity was split": "一个带标签的实体被拆分了",
"A workplane from picked geometry: on a planar face (x along an edge if one is picked, an offset along the normal), halfway between two parallel faces, through three vertices, or through an edge turned about it; or placed by hand (moved and turned with the handles) on XY / XZ / YZ, another workplane or a face. Sketch on it, or place features in it with `with wp:`.": "由所选几何生成工作平面:在平面上(选了边时 x 轴沿该边,可沿法向偏移)、两个平行面的中间、过三个顶点,或过一条边并绕它旋转;也可在 XY / XZ / YZ、其他工作平面或某个面上用手柄平移旋转手动放置。可在上面画草图,或用 `with wp:` 在其中放置特征。",
"A workplane from the selection (Space): a flat face, a face and an edge, two parallel faces, three vertices or an edge. New sketches go on it.": "由所选对象生成工作平面(空格):一个平面、一个面和一条边、两个平行面、三个顶点或一条边。新草图会画在上面。",
"A workplane needs one flat face, a face and an edge, two parallel faces, three vertices or one edge.": "创建工作平面需要:一个平面、一个面和一条边、两个平行面、三个顶点或一条边。",
"Accept this look-alike": "接受这个相似项",
"Actions for the selection": "当前选择可用的操作",
"Add": "添加",
"Add material along a sketch face to a body.": "沿草图面给实体增加材料。",
"Add material along a sketch to a body.": "沿草图给实体增加材料。",
"Add {{what}}": "添加{{what}}",
"Addendum factor": "齿顶高系数",
"Alias of `make_line_redge` that returns a straight edge.": "`make_line_redge` 的别名,返回一条直线边。",
"Amount": "数量",
"An assembly puts parts together: create a part first": "装配由零件组成:请先创建一个零件",
"An axis, the normal of the face you picked (into the material), or any vector.": "一个轴、所选面的法向(朝向材料内部),或任意向量。",
"An empty workspace. Start with a part: a notebook that builds one solid.": "工作区是空的。先建一个零件:一个构建单个实体的 notebook。",
"Angle": "角度",
"Angle about the edge": "绕边的角度",
"Angle arc → curve (edge)": "角度圆弧 → 曲线(边)",
"Angle arc → wire": "角度圆弧 → 线框",
"Apply a set boolean to two body groups, retaining every result solid.": "对两组实体做集合布尔运算,保留所有结果实体。",
"Apply chamfers, with optional tagging of kernel-proven patch faces.": "倒角,可选为内核确认的倒角面打标签。",
"Apply fillets, with optional tagging of kernel-proven patch faces.": "倒圆角,可选为内核确认的圆角面打标签。",
"Apply tag": "打标签",
"Assembly": "装配",
"Assembly id": "装配 id",
"Assembly layout": "装配布局",
"Assign a Material to a Part and return the updated Part.": "给零件指定材料,返回更新后的零件。",
"Assign material": "指定材料",
"At": "位置",
"Attach a connector datum frame to a Part definition.": "给零件定义附加一个连接器基准坐标系。",
"Axis": "轴",
"Axis point": "轴上一点",
"Backlash": "侧隙",
"Base": "基准",
"Belt constraint": "皮带约束",
"Bevel the picked edges.": "对所选的边倒角。",
"Bezier surface": "贝塞尔曲面",
"Body": "实体",
"Body id": "实体 id",
"Body to cut": "被切除的实体",
"Body to repeat": "要重复的实体",
"Bolt": "螺栓",
"Boolean": "布尔运算",
"Bore radius": "内孔半径",
"Boss": "凸台",
"Boss from sketch": "草图凸台",
"Bottom face center": "底面中心",
"Bottom face centre": "底面中心",
"Bottom radius": "底面半径",
"Box": "方块",
"Cancel": "取消",
"Carrier": "载体",
"Cell failed — run again (Ctrl+Enter)": "单元运行失败——重新运行(Ctrl+Enter)",
"Center": "中心",
"Centre": "中心",
"Chain pitch": "链节距",
"Chamfer": "倒角",
"Circle → curve (edge)": "圆 → 曲线(边)",
"Circle → face": "圆 → 面",
"Circle → wire": "圆 → 线框",
"Clean": "清理",
"Clear the log": "清空日志",
"Clearance factor": "顶隙系数",
"Click a point the arc passes through.": "点击圆弧经过的一点。",
"Click a sketch in the viewport or the features list to use it": "在视口或特征列表中点击草图来使用它",
"Click a solid, face, edge, vertex or sketch in the viewport (pick the kind with the chips). Ctrl/Cmd+click adds to the selection; picked model items are written to the notebook as": "在视口中点击实体、面、边、顶点或草图(用选择类型按钮切换要选的种类)。Ctrl/Cmd+点击可加选;选中的模型对象会写入 notebook,变量名为",
"Click again to delete": "再点一次删除",
"Click again to delete this cell": "再点一次删除此单元",
"Click the first point.": "点击第一个点。",
"Click the points the spline passes through; another tool or Enter ends it.": "依次点击样条经过的点;切换工具或按 Enter 结束。",
"Click where the arc ends.": "点击圆弧的终点。",
"Click where the line ends.": "点击直线的终点。",
"Close": "关闭",
"Close the log": "收起日志",
"Close the module view": "关闭模块视图",
"Closed": "闭合",
"Code mode": "代码模式",
"Collapse the command bar": "收起命令栏",
"Collapse the inspector": "收起检查器",
"Collapse the panel": "收起面板",
"Collapse to a pill": "收起为小按钮",
"Color": "颜色",
"Combine with": "与之合并",
"Combined with:": "与之合并:",
"Command bar": "命令栏",
"Component id": "组件 id",
"Components, the grounded one, and the joints and mates between connector frames.": "组件、被固定的组件,以及连接器坐标系之间的运动副和配合。",
"Compound from assembly": "由装配生成复合体",
"Compute the boolean difference of solids.": "计算实体的布尔差集。",
"Compute the boolean intersection of two 2D faces.": "计算两个二维面的布尔交集。",
"Compute the boolean union and return one manifold solid.": "计算布尔并集,返回一个流形实体。",
"Compute the boolean union of two 2D faces.": "计算两个二维面的布尔并集。",
"Cone": "圆锥",
"Cone / frustum": "圆锥 / 圆台",
"Connecting…": "正在连接…",
"Connector": "连接器",
"Connector a": "连接器 a",
"Connector b": "连接器 b",
"Connector id": "连接器 id",
"Connector ref": "连接器引用",
"Constrain two component connectors to the same frame.": "把两个组件的连接器约束到同一坐标系。",
"Constrain two connectors as a prismatic slider pair.": "把两个连接器约束为移动副。",
"Constrain two connectors as a revolute axis pair.": "把两个连接器约束为转动副。",
"Constraint id": "约束 id",
"Control points": "控制点",
"Convert a face's surface (and its boundary curves) to B-splines, so the surface edits can work on it.": "把面的曲面(及其边界曲线)转换为 B 样条,以便进行曲面编辑。",
"Convert an edge's curve to a B-spline, so the curve edits can work on it.": "把边的曲线转换为 B 样条,以便进行曲线编辑。",
"Convert to bspline → curve (edge)": "转为 B 样条 → 曲线(边)",
"Convert to bspline → face": "转为 B 样条 → 面",
"Copies of a body along a direction (the original is the first copy).": "沿一个方向复制实体(原实体是第一份)。",
"Copies of a body around an axis.": "绕一个轴复制实体。",
"Copy a reference to this cell for a coding agent (Alt/Shift+click: with its code)": "复制此单元的引用给编程 agent(Alt/Shift+点击:连同代码)",
"Could not create the notebook.": "无法创建 notebook。",
"Count": "数量",
"Couple a prismatic rack axis to a revolute pinion axis.": "把齿条的移动轴与小齿轮的转动轴耦合。",
"Couple two revolute axes as belt-linked pulleys with same-direction rotation.": "把两个转动轴耦合为皮带连接的带轮,同向转动。",
"Couple two revolute axes as meshing gears with inverse rotation.": "把两个转动轴耦合为啮合齿轮,反向转动。",
"Create": "创建",
"Create a Gordon Face from intersecting profile and guide edge networks.": "由相交的截面边网格和导引边网格生成 Gordon 面。",
"Create a bolt along +Z with its head underside on the Z=0 plane.": "沿 +Z 创建螺栓,头部下表面位于 Z=0 平面。",
"Create a box with native kernel-backed Face topology tags.": "创建带内核面拓扑标签的长方体。",
"Create a canonical right-handed placement in the active workplane.": "在当前工作平面中创建标准右手位姿。",
"Create a circular edge.": "创建圆形边。",
"Create a circular face.": "创建圆形面。",
"Create a circular wire.": "创建圆形线框。",
"Create a closed scalar limit for driven constraint coordinates.": "为驱动约束坐标创建闭区间标量极限。",
"Create a cone or frustum with native kernel-backed topology tags.": "创建带内核拓扑标签的圆锥或圆台。",
"Create a connector anchored to a Face.": "创建锚定在面上的连接器。",
"Create a connector anchored to a Vertex.": "创建锚定在顶点上的连接器。",
"Create a connector anchored to an Edge.": "创建锚定在边上的连接器。",
"Create a connector anchored to an explicit local placement frame.": "创建锚定在显式局部位姿坐标系上的连接器。",
"Create a cycloidal reducer disc for a one-tooth-difference pin ring.": "为一齿差针齿圈创建摆线减速器摆线盘。",
"Create a cylinder with native kernel-backed Face and Edge topology tags.": "创建带内核面和边拓扑标签的圆柱。",
"Create a face from a closed wire.": "由闭合线框创建面。",
"Create a face from one outer closed wire and optional inner closed wires.": "由一个闭合外线框和可选的闭合内线框创建面。",
"Create a full ellipse edge.": "创建完整的椭圆边。",
"Create a helical rack.": "创建斜齿齿条。",
"Create a helix edge, right- or left-handed.": "创建螺旋线边,右旋或左旋。",
"Create a helix wire, right- or left-handed.": "创建螺旋线线框,右旋或左旋。",
"Create a herringbone rack.": "创建人字齿条。",
"Create a linear pattern of solids.": "创建实体的线性阵列。",
"Create a lofted solid, with optional kernel-role-based tags.": "创建放样实体,可选按内核角色打标签。",
"Create a material definition for later Part assignment.": "创建材料定义,供之后指定给零件。",
"Create a notebook first": "请先新建 notebook",
"Create a nut along +Z with its bottom face on the Z=0 plane.": "沿 +Z 创建螺母,底面位于 Z=0 平面。",
"Create a point in 3D space and return it as a vertex.": "在三维空间中创建一个点,以顶点形式返回。",
"Create a polyline wire from a point list.": "由点列表创建多段线线框。",
"Create a radial pattern of solids.": "创建实体的环形阵列。",
"Create a recorded workplane from an origin, a normal and an x direction.": "由原点、法向和 x 方向创建一个被记录的工作平面。",
"Create a rectangular face.": "创建矩形面。",
"Create a rectangular wire.": "创建矩形线框。",
"Create a revolved solid, with optional kernel-role-based tags.": "创建旋转实体,可选按内核角色打标签。",
"Create a roller-chain sprocket from the chain engagement dimensions.": "按链条啮合尺寸创建滚子链链轮。",
"Create a ruled Face spanning two compatible edges.": "在两条兼容的边之间创建直纹面。",
"Create a solid by extruding a profile, with optional role-based tags.": "拉伸轮廓创建实体,可选按角色打标签。",
"Create a solid by sweeping a profile along a helical path.": "沿螺旋路径扫掠轮廓创建实体。",
"Create a sphere solid.": "创建球体。",
"Create a straight bevel gear with standard metric tooth proportions.": "按标准公制齿形比例创建直齿锥齿轮。",
"Create a straight edge between two points.": "在两点之间创建直线边。",
"Create a straight-tooth rack.": "创建直齿齿条。",
"Create a swept solid, with optional kernel-role-based tags.": "创建扫掠实体,可选按内核角色打标签。",
"Create a trimmed Face carrying a tensor-product Bezier surface.": "创建承载张量积贝塞尔曲面的裁剪面。",
"Create a wire containing a single straight segment.": "创建只含一条直线段的线框。",
"Create a wire containing an arc defined by a center, radius, and angle range.": "创建一条线框,包含由圆心、半径和角度范围定义的圆弧。",
"Create a wire containing an arc defined by three points.": "创建一条线框,包含由三点定义的圆弧。",
"Create a wire from a list of connected edges.": "由一组相连的边创建线框。",
"Create a workplane moved and turned relative to a workplane or a named plane.": "相对于某个工作平面或命名平面平移并旋转,创建工作平面。",
"Create a workplane normal to a curve: the plane of a sweep profile.": "创建垂直于曲线的工作平面,即扫掠轮廓所在的平面。",
"Create a workplane on a planar face of the model.": "在模型的一个平面上创建工作平面。",
"Create a workplane through an axis, turned about it by an angle.": "创建过一条轴并绕它旋转一定角度的工作平面。",
"Create an arc edge from a center, radius, and angle range.": "由圆心、半径和角度范围创建圆弧边。",
"Create an arc edge from three points.": "由三点创建圆弧边。",
"Create an elliptical face.": "创建椭圆面。",
"Create an elliptical wire.": "创建椭圆线框。",
"Create an empty assembly product structure.": "创建一个空的装配产品结构。",
"Create an internal helical ring gear.": "创建斜齿内齿圈。",
"Create an internal herringbone ring gear.": "创建人字内齿圈。",
"Create an internal spur ring gear.": "创建直齿内齿圈。",
"Create an involute helical gear.": "创建渐开线斜齿轮。",
"Create an involute herringbone (double-helical) gear.": "创建渐开线人字齿轮(双斜齿)。",
"Create an involute spur gear (straight teeth, helix angle = 0).": "创建渐开线直齿轮(直齿,螺旋角为 0)。",
"Create an open loft Shell with endpoint-Wire and side-Face naming.": "创建开放的放样壳,并为端部线框和侧面命名。",
"Create an oriented Solid from one valid closed Shell.": "由一个有效的闭合壳创建有方向的实体。",
"Create the workplane halfway between two parallel planar faces (a symmetry plane).": "在两个平行平面的中间创建工作平面(对称面)。",
"Curve": "曲线",
"Curves": "曲线",
"Cut": "切除",
"Cut a body along a sketch face (a pocket or a through cut).": "沿草图面切除实体(凹槽或贯穿切除)。",
"Cut a pocket or a through cut along a sketch.": "沿草图切出凹槽或贯穿切除。",
"Cut sketch": "草图切除",
"Cut with sketch": "用草图切除",
"Cycloidal disc": "摆线盘",
"Cylinder": "圆柱",
"Datums": "基准",
"Declare the frames of this part (from picked faces) that an assembly joins by.": "声明此零件供装配连接用的坐标系(取自所选面)。",
"Degree": "阶次",
"Degree max": "最高阶次",
"Degree min": "最低阶次",
"Delete this cell": "删除此单元",
"Delete this feature": "删除此特征",
"Delete {{name}} (kept in .sca-editor/trash)": "删除 {{name}}(移到 .sca-editor/trash 中保留)",
"Density": "密度",
"Depth": "深度",
"Depth (z)": "深度(z)",
"Diameter": "直径",
"Dir": "方向",
"Direction": "方向",
"Direction into the material": "朝向材料内部的方向",
"Direction x": "方向 x",
"Direction y": "方向 y",
"Direction z": "方向 z",
"Dismiss": "关闭提示",
"Distance": "距离",
"Dock at the bottom": "停靠到底部",
"Dock at the top": "停靠到顶部",
"Draft": "拔模",
"Draft planar, cylindrical or conical faces by a signed angle in degrees.": "按带符号的角度(度)对平面、圆柱面或圆锥面拔模。",
"Draw a path in space (W): lines, arcs and splines on workplanes, snapped to the model; it becomes a wire to sweep along or loft through.": "在空间中绘制路径(W):在工作平面上画直线、圆弧和样条,并吸附到模型;生成的线框可用于扫掠或放样。",
"Drive angle degrees": "驱动角度(度)",
"Drive depth": "驱动深度",
"Drive distance": "驱动距离",
"Drive size": "驱动尺寸",
"Drive style": "驱动方式",
"Drop the edited values; back to what the source says": "丢弃修改的值,恢复为源码中的值",
"Eccentricity": "偏心距",
"Edge": "边",
"Edge a": "边 a",
"Edge b": "边 b",
"Edge connector": "边连接器",
"Edges": "边",
"Edit sketch": "编辑草图",
"Edit this feature": "编辑此特征",
"Edit {{what}}": "编辑{{what}}",
"Editor mode": "编辑器模式",
"Elevate curve degree": "升高曲线阶次",
"Elevate surface degree": "升高曲面阶次",
"Ellipse → curve (edge)": "椭圆 → 曲线(边)",
"Ellipse → face": "椭圆 → 面",
"Ellipse → wire": "椭圆 → 线框",
"End": "终点",
"End angle": "终止角",
"Every operation and drawing is written into a notebook. Create one first (it starts empty).": "所有操作和绘图都会写入 notebook。请先新建一个(新建的 notebook 是空的)。",
"Expose an existing connector on a direct child component.": "把直接子组件上已有的连接器公开出来。",
"Extrude": "拉伸",
"Extrude (cut)": "拉伸(切除)",
"Extrude (join)": "拉伸(合并)",
"Extrude a planar face until a target surface, including curved surfaces.": "把平面拉伸到目标表面为止(包括曲面)。",
"Extrude a planar sketch face by a vector, with a taper in degrees.": "按向量拉伸平面草图面,并带拔模角(度)。",
"Extrude face": "拉伸面",
"Extrude sketch": "拉伸草图",
"Extrude taper": "带拔模角拉伸",
"Extrude until": "拉伸至",
"Face": "面",
"Face a": "面 a",
"Face b": "面 b",
"Face connector": "面连接器",
"Face from wire": "由线框生成面",
"Face from wires": "由多个线框生成面",
"Face width": "齿宽",
"Faces": "面",
"Faces to draft": "要拔模的面",
"Faces to open": "要开口的面",
"Faces to remove": "要移除的面",
"Factor": "系数",
"Features": "特征",
"Fill holes": "填补孔洞",
"Fill selected closed free boundaries and return a sewn Shell.": "填补所选的闭合自由边界,返回缝合后的壳。",
"Fillet": "圆角",
"Finish": "完成",
"First body": "第一个实体",
"Fit a B-spline Face through a rectangular 3D point grid.": "用 B 样条面拟合一个矩形三维点阵。",
"Fit point grid": "拟合点阵",
"Fixed constraint": "固定约束",
"Flip": "翻转",
"Flip inner": "翻转内侧",
"Flip the normal": "翻转法向",
"Fold every cell to its name": "把所有单元折叠为名称",
"Fold to its name": "折叠为名称",
"Free boundaries": "自由边界",
"From": "起点",
"Gear constraint": "齿轮约束",
"Gear height": "齿轮高度",
"Glue": "粘合",
"Gordon surface": "Gordon 曲面",
"Ground a component at its current authored placement.": "把组件固定在当前设定的位姿上。",
"Ground component": "固定组件",
"Guide radius": "导引半径",
"Guides": "导引线",
"Handedness": "旋向",
"Head height": "头部高度",
"Head style": "头部样式",
"Head width": "头部宽度",
"Height": "高度",
"Height (y)": "高度(y)",
"Helical gear": "斜齿轮",
"Helical rack": "斜齿齿条",
"Helical ring gear": "斜齿内齿圈",
"Helical sweep": "螺旋扫掠",
"Helix angle": "螺旋角",
"Helix → curve (edge)": "螺旋线 → 曲线(边)",
"Helix → wire": "螺旋线 → 线框",
"Herringbone gear": "人字齿轮",
"Herringbone rack": "人字齿条",
"Herringbone ring gear": "人字内齿圈",
"Hide highlight": "隐藏高亮",
"Hide this sketch in the viewport": "在视口中隐藏此草图",
"Hole": "孔",
"Hole depth": "孔深",
"Hole here": "在此打孔",
"Hole style": "孔类型",
"Holes": "孔",
"Hollow the body, opening the picked faces.": "把实体挖空,并打开所选的面。",
"How the new solid meets the body so far: join it, cut it out, keep only what they share, or (when there is no body yet) start it.": "新实体与已有实体的关系:合并、切除、只保留公共部分,或(还没有实体时)作为起始实体。",
"Inner wires": "内线框",
"Insert a U or V knot into a face's B-spline surface at ``parameter`` (strictly inside the surface's domain in that direction).": "在面的 B 样条曲面的 ``parameter`` 处插入一个 U 或 V 节点(必须严格位于该方向的参数域内部)。",
"Insert a cell here": "在此插入单元",
"Insert a knot into an edge's B-spline curve at ``parameter`` (strictly inside the edge's parameter range).": "在边的 B 样条曲线的 ``parameter`` 处插入节点(必须严格位于边的参数范围内部)。",
"Insert curve knot": "插入曲线节点",
"Insert surface knot": "插入曲面节点",
"Intersect": "相交",
"Is frenet": "Frenet 标架",
"Join": "合并",
"Join two bodies into one.": "把两个实体合并为一个。",
"Join with the original": "与原实体合并",
"Keep only what two bodies share.": "只保留两个实体的公共部分。",
"Kind": "类型",
"Knurl count": "滚花数",
"Language (click: {{next}})": "语言(点击切换为 {{next}})",
"Left": "左",
"Length": "长度",
"Line": "直线",
"Lineage policy": "血缘策略",
"Linear pattern": "线性阵列",
"Loft → solid": "放样 → 实体",
"Loft → surface": "放样 → 曲面",
"Lower value": "下限值",
"Major direction": "主方向",
"Major radius": "长半径",
"Manual mode": "手动模式",
"Material": "材料",
"Material id": "材料 id",
"Max control points": "最大控制点数",
"Middle": "中点",
"Minor radius": "短半径",
"Mirror": "镜像",
"Mirror a body in a plane, and optionally join the halves.": "以平面镜像实体,可选把两半合并。",
"Model with buttons and dialogs: features, sketches, assemblies": "用按钮和对话框建模:特征、草图、装配",
"Module": "模数",
"More": "更多",
"Move": "移动",
"Move (G)": "平移(G)",
"Move a body by an offset.": "按偏移量移动实体。",
"Move an existing assembly component by replacing its placement.": "替换位姿以移动装配中已有的组件。",
"Multiplicity": "重数",
"N lobes": "凸瓣数",
"N teeth": "齿数",
"Name": "名称",
"Name of the new notebook": "新 notebook 的名称",
"New body": "新建实体",
"No features yet. Add a Box or another operation from the command bar; each one becomes an ordinary cell in the notebook.": "还没有特征。从命令栏添加方块或其他操作,每个操作都会成为 notebook 中的一个普通单元。",
"No notebook is open": "当前没有打开的 notebook",
"No notebook is open: create one first.": "当前没有打开的 notebook:请先新建一个。",
"No notebook yet: create one in the workspace tab": "还没有 notebook:请在工作区标签页中新建",
"Normal": "法向",
"Notebook name": "Notebook 名称",
"Nothing yet. Runs, reloads and errors are listed here.": "暂无记录。运行、重载和错误会列在这里。",
"Nut": "螺母",
"Nut style": "螺母样式",
"Offset": "偏移",
"Offset a solid outward (positive) or inward (negative).": "向外(正值)或向内(负值)偏移实体。",
"Offset along the normal": "沿法向偏移",
"On split": "被拆分时",
"Opacity": "不透明度",
"Open the inspector": "展开检查器",
"Open the log": "展开日志",
"Open the panel": "展开面板",
"Open the selected sketch for editing.": "打开所选草图进行编辑。",
"Openings": "开口",
"Operation": "操作",
"Operations": "操作",
"Origin": "原点",
"Origin vertex": "原点顶点",
"Outer": "外侧",
"Outer wire": "外线框",
"Output pin clearance radius": "输出销间隙半径",
"Output pin count": "输出销数量",
"Output pin phase": "输出销相位",
"Output pin pitch radius": "输出销分布圆半径",
"Parameter": "参数",
"Part": "零件",
"Part connectors": "零件连接器",
"Part id": "零件 id",
"Path": "路径",
"Pattern": "阵列",
"Phase offset": "相位偏移",
"Pick a face to fill the point and direction.": "选择一个面来填入点和方向。",
"Pick again to replace them.": "重新选择可替换它们。",
"Pick edges in the viewport; Ctrl/Cmd+click adds.": "在视口中选择边;Ctrl/Cmd+点击加选。",
"Pick exactly one face in the viewport first.": "请先在视口中只选择一个面。",
"Pick faces in the viewport; Ctrl/Cmd+click adds.": "在视口中选择面;Ctrl/Cmd+点击加选。",
"Pick one flat face of the body.": "选择实体上的一个平面。",
"Pinion connector": "小齿轮连接器",
"Pitch": "节距",
"Pitch angle": "节锥角",
"Pitch radius": "节圆半径",
"Pitch radius a": "节圆半径 a",
"Pitch radius b": "节圆半径 b",
"Place a connector of this part on the picked flat face: move and turn its frame with the handles, then add it (assemblies join parts at connectors).": "在所选平面上放置此零件的连接器:用手柄平移旋转其坐标系后添加(装配通过连接器连接零件)。",
"Place a workplane with handles (Space): on the picked flat face, else on the active workplane, else on XY; move and turn it, then sketch on it.": "用手柄放置工作平面(空格):放在所选平面上,否则放在当前工作平面上,再否则放在 XY 上;平移旋转后即可在上面画草图。",
"Place component": "放置组件",
"Place parts, ground one, and join connector frames with joints and mates.": "放置零件、固定其中一个,并用运动副和配合连接各连接器坐标系。",
"Placement": "位姿",
"Placement connector": "位姿连接器",
"Plane normal": "平面法向",
"Plane origin": "平面原点",
"Plane point": "平面上一点",
"Plane {{plane}}, normal": "平面 {{plane}},法向",
"Point": "点",
"Points": "点",
"Pole count": "控制点数",
"Poles": "控制点",
"Polyline": "多段线",
"Pressure angle": "压力角",
"Primitives": "基本体",
"Prismatic constraint": "移动副约束",
"Product": "产品",
"Profile": "轮廓",
"Profiles": "轮廓",
"Project an Assembly into an explicit flattened Compound geometry value.": "把装配展平为一个显式的复合体几何。",
"Public connector id": "公开连接器 id",
"Pull face": "拉出面",
"Pulley radius a": "带轮半径 a",
"Pulley radius b": "带轮半径 b",
"Push a flat face of the body out (or into it) along its normal, without a sketch.": "不画草图,直接把实体的平面沿法向向外推出(或向内压入)。",
"Push a sketch face along a direction.": "沿某个方向推出草图面。",
"Push a sketch out into a solid.": "把草图推出成实体。",
"Push face in": "压入面",
"Push in": "压入",
"Push the other way (the arrow in the viewport turns)": "反向推出(视口中的箭头会随之翻转)",
"Push the picked face into the body and remove what it passes.": "把所选面压入实体,去除经过的部分。",
"Push the picked face out along its normal and add it to the body.": "把所选面沿法向拉出并加到实体上。",
"Push the sketch out and add it to the body.": "把草图推出并加到实体上。",
"Push the sketch through the body and remove what it passes.": "把草图推入实体,去除经过的部分。",
"Rack connector": "齿条连接器",
"Rack height": "齿条高度",
"Rack pinion constraint": "齿轮齿条约束",
"Radial pattern": "环形阵列",
"Radius": "半径",
"Raise the U and/or V degree of a face's B-spline surface.": "升高面的 B 样条曲面的 U 和/或 V 阶次。",
"Raise the degree of an edge's B-spline curve to ``degree``.": "把边的 B 样条曲线升到 ``degree`` 阶。",
"Rebuild curve": "重建曲线",
"Rebuild surface": "重建曲面",
"Rectangle → face": "矩形 → 面",
"Rectangle → wire": "矩形 → 线框",
"Redo (Ctrl/Cmd+Shift+Z)": "重做(Ctrl/Cmd+Shift+Z)",
"Reference a connector through a component instance.": "通过组件实例引用一个连接器。",
"Reference direction": "参考方向",
"Refit a face's surface as a B-spline of the given degrees and pole counts, or with the fewest poles that keep within ``tolerance``.": "按给定阶次和控制点数把面的曲面重新拟合为 B 样条,或用满足 ``tolerance`` 的最少控制点拟合。",
"Refit an edge's curve as a B-spline of ``degree`` with ``pole_count`` poles, or with the fewest poles that keep within ``tolerance``.": "把边的曲线重新拟合为 ``degree`` 阶、``pole_count`` 个控制点的 B 样条,或用满足 ``tolerance`` 的最少控制点拟合。",
"Remove a component grounding marker.": "取消组件的固定标记。",
"Reset": "重置",
"Return a semantic shape view with a canonical tag assignment.": "返回带规范标签的语义形体视图。",
"Return unique closed and open free boundary wires of a Shell.": "返回壳上不重复的闭合与开放自由边界线框。",
"Revolute constraint": "转动副约束",
"Revolve": "旋转",
"Revolve sketch": "旋转草图",
"Right": "右",
"Rim thickness": "轮缘厚度",
"Ring pin pitch radius": "针齿分布圆半径",
"Roller chain sprocket": "滚子链链轮",
"Roller clearance": "滚子间隙",
"Roller diameter": "滚子直径",
"Roller radius": "滚子半径",
"Rotate": "旋转变换",
"Round the picked edges.": "对所选的边倒圆角。",
"Ruled": "直纹",
"Ruled surface": "直纹面",
"Run every cell": "运行所有单元",
"Run every cell above this one": "运行此单元之上的所有单元",
"Run this cell (Ctrl+Enter)": "运行此单元(Ctrl+Enter)",
"Sample an edge for a curvature comb: ``count`` points evenly in its parameter range.": "为曲率梳采样一条边:在其参数范围内均匀取 ``count`` 个点。",
"Sample count per lobe": "每个凸瓣的采样数",
"Sample curve": "曲线采样",
"Sample isocurves of a face, clipped to its trimming.": "采样面的等参线,并按其裁剪边界截断。",
"Sample surface": "曲面采样",
"Samples": "采样数",
"Scalar limit": "标量极限",
"Scale": "缩放",
"Scale a body uniformly about a point.": "以一点为中心等比缩放实体。",
"Scope": "范围",
"Search operations": "搜索操作",
"Second body": "第二个实体",
"Second face": "第二个面",
"Sections": "截面",
"Segment → curve (edge)": "线段 → 曲线(边)",
"Segment → wire": "线段 → 线框",
"Set body appearance": "设置实体外观",
"Set curve poles": "设置曲线控制点",
"Set every pole of a face's B-spline surface.": "设置面的 B 样条曲面的全部控制点。",
"Set every pole of an edge's B-spline curve.": "设置边的 B 样条曲线的全部控制点。",
"Set public connector": "设置公开连接器",
"Set surface poles": "设置曲面控制点",
"Set the display colour, opacity and display name of one body of a Part.": "设置零件中某个实体的显示颜色、不透明度和显示名称。",
"Sew faces": "缝合面",
"Sew faces into exactly one connected Shell.": "把面缝合为一个连通的壳。",
"Shape": "形体",
"Shell": "抽壳",
"Shell a solid, with optional kernel-role-based face tags.": "对实体抽壳,可选按内核角色给面打标签。",
"Show highlight": "显示高亮",
"Show the command bar": "显示命令栏",
"Show the command bar (/ or Ctrl/Cmd+K)": "显示命令栏(/ 或 Ctrl/Cmd+K)",
"Show this sketch in the viewport": "在视口中显示此草图",
"Sketch": "草图",
"Sketch (list)": "草图(列表)",
"Sketch on face": "在面上画草图",
"Sketch on this face": "在此面上画草图",
"Sketch profile": "草图轮廓",
"Sketch:": "草图:",
"Skip non intersecting": "跳过不相交的",
"Snaps to vertices, edge midpoints, workplane origins, its own points and the grid. Tab: next plane · ⌫: back": "吸附到顶点、边中点、工作平面原点、已画的点和网格。Tab:下一个平面 · ⌫:回退",
"Solid": "实体",
"Solid from shell": "由壳生成实体",
"Solids": "实体",
"Source component id": "源组件 id",
"Source connector id": "源连接器 id",
"Spacing": "间距",
"Sphere": "球体",
"Spline tolerance": "样条公差",
"Sprocket thickness": "链轮厚度",
"Spur gear": "直齿轮",
"Spur rack": "直齿齿条",
"Spur ring gear": "直齿内齿圈",
"Standard library": "标准件库",
"Start": "起点",
"Start a new, empty notebook": "新建一个空白 notebook",
"Start a sketch on the selected flat face.": "在所选平面上开始画草图。",
"Start angle": "起始角",
"Start point (on the surface)": "起点(在曲面上)",
"Start point placed at ({{point}}).": "起点已放在({{point}})。",
"Start point set from the face centroid. The face reports no normal: check the direction.": "起点取自面的形心。这个面没有法向信息:请检查方向。",
"Start point set from the face centroid; the hole follows the face's normal, into the material ({{normal}}).": "起点取自面的形心;孔沿面的法向打入材料({{normal}})。",
"Starts with {{parts}}; change what it uses in its cells.": "以 {{parts}} 开始;可在其单元中修改所用零件。",
"Stop the run (interrupt the kernel)": "停止运行(中断内核)",
"Straight bevel gear": "直齿锥齿轮",
"Subtract one 2D face from another (2D boolean difference).": "从一个二维面中减去另一个(二维布尔差集)。",
"Surfaces": "曲面",
"Sweep": "扫掠",
"Sweep a planar profile along a straight axis with linear rotation.": "沿直线轴扫掠平面轮廓,并线性旋转。",
"Sweep multisection": "多截面扫掠",
"Sweep through explicit ordered sections along a continuous path.": "沿连续路径依次经过给定的截面进行扫掠。",
"Tag": "标签",
"Take one or more bodies out of another.": "从一个实体中去除一个或多个实体。",
"Taper": "拔模角",
"Target": "目标",
"Targets": "目标",
"That face is not flat: a workplane lies on a plane. Pick a flat face, or nothing to place one on the active workplane.": "这个面不是平面:工作平面必须位于平面上。请选择一个平面,或不选任何东西以放在当前工作平面上。",
"The body this feature works on (default: the last one made).": "此特征作用的实体(默认:最近创建的那个)。",
"The body this solid is joined to, cut from or intersected with (default: the body so far).": "此实体要与之合并、从中切除或求交的实体(默认:当前已有的实体)。",
"The face details are still loading; try again in a moment.": "面的详情仍在加载,请稍后再试。",
"The model before {{step}}": "{{step}} 之前的模型",
"The notebook behind the model: cells, parameters, the workspace": "模型背后的 notebook:单元、参数、工作区",
"The origin's offset along the base's own x, y and normal (mm).": "原点沿基准自身的 x、y 和法向的偏移(mm)。",
"The part is this body (made by the runtime, no cell to keep)": "零件就是这个实体(由运行时生成,不需要单独的单元)",
"The product cell builds from this body": "产品单元由这个实体构建",
"The product still builds from": "产品仍由此实体构建:",
"Theme: {{theme}} (click: {{next}})": "主题:{{theme}}(点击切换为{{next}})",
"Theme: {{theme}}. Switch to {{next}}": "主题:{{theme}}。切换为{{next}}",
"Thickness": "厚度",
"Third vertex": "第三个顶点",
"This face has no centroid; type the start point.": "这个面没有形心,请手动输入起点。",
"This face is a {{type}}: a sketch needs a flat face. Pick a flat face or a datum plane.": "这个面是 {{type}}:草图需要平面。请选择一个平整的面或基准平面。",
"This face is curved: a sketch needs a flat face. Pick a flat face or a datum plane.": "这个面是曲面:草图需要平面。请选择一个平整的面或基准平面。",
"This sketch has several loops; it uses what was chosen in the sketch ({{summary}}).": "这个草图有多个环;使用草图中所选的部分({{summary}})。",
"Thread depth": "螺纹深度",
"Thread detail": "螺纹细节",
"Thread form": "螺纹牙型",
"Thread length": "螺纹长度",
"Thread pitch": "螺距",
"Thread style": "螺纹样式",
"Three point arc → curve (edge)": "三点圆弧 → 曲线(边)",
"Three point arc → wire": "三点圆弧 → 线框",
"Tol": "公差",
"Tolerance": "公差",
"Tool": "工具体",
"Tool (taken out)": "工具体(被去除)",
"Top radius": "顶面半径",
"Topology propagation": "拓扑传播",
"Total angle": "总角度",
"Total rotation angle": "总旋转角",
"Transform": "变换",
"Trim a carrier Face to exactly one connected Face.": "把承载面裁剪为一个连通的面。",
"Trim surface": "修剪曲面",
"Turn (R)": "旋转(R)",
"Turn a body about an axis.": "绕轴旋转实体。",
"Turn a sketch around an axis into a solid.": "把草图绕轴旋转成实体。",
"Turn a sketch face about an axis.": "绕轴旋转草图面。",
"Turn about the normal": "绕法向旋转",
"Turn about x": "绕 x 旋转",
"Turn about y": "绕 y 旋转",
"Twist angle": "扭转角",
"Twisted sweep": "扭转扫掠",
"U count": "U 数量",
"U degree": "U 阶次",
"U pole count": "U 控制点数",
"Underhead fillet radius": "头下圆角半径",
"Undo the last feature change (Ctrl/Cmd+Z)": "撤销上一次特征修改(Ctrl/Cmd+Z)",
"Unfold": "展开",
"Unfold every cell": "展开所有单元",
"Unground component": "取消固定组件",
"Union": "合并",
"Until": "直到",
"Upper value": "上限值",
"Use letters, digits, - and _, starting with a letter or _.": "只能使用字母、数字、- 和 _,并以字母或 _ 开头。",
"Use this piece": "使用这一块",
"Used by {{users}}: drawn dimmer in the viewport": "被 {{users}} 使用:在视口中淡化显示",
"V count": "V 数量",
"V degree": "V 阶次",
"V pole count": "V 控制点数",
"Vector": "向量",
"Vertex": "顶点",
"Vertex connector": "顶点连接器",
"Waiting for the kernel to publish cells…": "等待内核发布单元…",
"Wall thickness": "壁厚",
"Width": "宽度",
"Width (x)": "宽度(x)",
"Wire": "线框",
"Wire from edges": "由边生成线框",
"Workplane": "工作平面",
"Workplane from axis": "由轴生成工作平面",
"Workplane from face": "由面生成工作平面",
"Workplane from selection": "由所选对象生成工作平面",
"Workplane midplane": "中间工作平面",
"Workplane normal to curve": "垂直于曲线的工作平面",
"Workplane offset": "偏移工作平面",
"Wrap one Solid, or several named solids, as a semantic Part.": "把一个实体(或多个具名实体)包装为语义零件。",
"Write the edited values into the notebook source": "把修改的值写入 notebook 源码",
"Written as code: edit it in the notebook": "以代码形式编写:请在 notebook 中编辑",
"X axis": "X 轴",
"X dir": "X 方向",
"X edge": "X 方向边",
"XY, XZ or YZ, the name of a workplane of the notebook, or face (the picked face).": "XY、XZ 或 YZ,notebook 中某个工作平面的名称,或 face(所选面)。",
"Y axis": "Y 轴",
"a cell changed on disk while you were editing it: kept the file's version. Your unsaved text was:": "你编辑期间,这个单元在磁盘上被修改了:已保留文件中的版本。你未保存的内容是:",
"a free vector": "自由向量",
"add": "添加",
"add feature": "添加特征",
"adds this solid to the body": "把这个实体加到已有实体上",
"against the normal of the sketch plane": "逆着草图平面的法向",
"along the picked face's normal": "沿所选面的法向",
"already used": "已被使用",
"apply": "应用",
"arc": "圆弧",
"assembly": "装配",
"auto": "自动",
"base": "基准",
"blind": "盲孔",
"blocked": "被阻塞",
"build": "构建",
"building the model": "正在构建模型",
"button": "圆头",
"cancel": "取消",
"clear": "清除",
"click to add it (the order of the clicks is the order)": "点击加入(点击的先后就是顺序)",
"comp": "组件",
"confirm delete {{name}}": "确认删除 {{name}}",
"connectors set": "已设置连接器",
"cosmetic": "示意",
"countersunk": "沉头",
"create": "创建",
"created {{path}}": "已创建 {{path}}",
"creating {{name}}": "正在创建 {{name}}",
"cross": "十字",
"ctrl+click: add": "Ctrl+点击:加选",
"cut": "切除",
"cylindrical": "圆柱头",
"dark": "深色",
"datum": "基准",
"definition": "定义",
"delete": "删除",
"delete {{name}}": "删除 {{name}}",
"deleted {{path}} (kept in {{trash}})": "已删除 {{path}}(保留在 {{trash}})",
"details of the picked items are still loading": "所选对象的详情仍在加载",
"downward": "向下",
"drag the arrows to move, the rings to turn · Shift: no snapping": "拖动箭头平移,拖动圆环旋转 · Shift:不吸附",
"drawing plane": "绘图平面",
"edge": "边",
"edit {{name}}": "编辑 {{name}}",
"empty notebook: add the first feature": "空白 notebook:请添加第一个特征",
"entity": "实体",
"error": "错误",
"explicit": "显式",
"exported {{path}}": "已导出 {{path}}",
"face": "面",
"failed": "失败",
"features": "特征",
"fit": "适配视图",
"fits selection": "适用于当前选择",
"flip": "翻转",
"fold all": "全部折叠",
"full": "完整",
"function": "函数",
"geometry": "几何",
"halfway between two parallel faces": "两个平行面的中间",
"hex": "六角",
"hex_socket": "内六角",
"hide {{name}} in the viewport": "在视口中隐藏 {{name}}",
"inspector": "检查器",
"intersect": "相交",
"into the body (against the normal)": "朝向实体内部(逆法向)",
"keep": "保留",
"keeps only what both share": "只保留两者的公共部分",
"kept from the recipe": "沿用原有的选择规则",
"kernel running": "内核运行中",
"kernel stopped": "内核已停止",
"knurled": "滚花",
"light": "浅色",
"line": "直线",
"loading": "加载中",
"loading details…": "正在加载详情…",
"local": "局部",
"log": "日志",
"model shown: 1 part": "已显示模型:1 个零件",
"model shown: {{count}} parts": "已显示模型:{{count}} 个零件",
"modeled": "建模",
"modifier": "修改",
"move": "平移",
"moved and turned from a plane, a workplane or a face": "从平面、工作平面或面平移并旋转得到",
"name": "名称",
"name, e.g. bracket": "名称,例如 bracket",
"new": "新建",
"no body yet": "还没有实体",
"no notebook": "未打开 notebook",
"no sketch yet": "还没有草图",
"no {{what}} in this notebook yet": "此 notebook 中还没有 {{what}}",
"no {{what}} yet": "还没有 {{what}}",
"node": "节点",
"none": "无",
"none picked": "未选择",
"normal of the sketch plane": "草图平面的法向",
"notebook": "Notebook",
"notebooks": "notebook 列表",
"on": "位于",
"on a face": "在面上",
"on a face, x along an edge": "在面上,x 轴沿一条边",
"open bodies": "可用实体",
"open failed: {{reason}}": "打开失败:{{reason}}",
"opening {{name}}": "正在打开 {{name}}",
"out of the face (its normal)": "离开面(沿法向)",
"panel": "面板",
"part": "零件",
"partial": "部分",
"pick edges in the viewport": "请在视口中选择边",
"pick faces in the viewport": "请在视口中选择面",
"pick in viewport": "在视口中拾取",
"picked face": "所选面",
"picking…": "拾取中…",
"pieces": "分块",
"product": "产品",
"properties": "属性",
"pushes against the sketch normal ({{axis}}); the arrow in the viewport shows it": "逆着草图法向({{axis}})推出;视口中的箭头表示方向",
"pushes along the sketch normal ({{axis}}); the arrow in the viewport shows it": "沿草图法向({{axis}})推出;视口中的箭头表示方向",
"queued": "排队中",
"re-evaluating {{done}}/{{total}}": "重新计算 {{done}}/{{total}}",
"redo": "重做",
"references:": "引用:",
"removes this solid from the body": "从已有实体中去除这个实体",
"revert": "还原",
"round": "圆形",
"run all": "全部运行",
"running": "运行中",
"running all cells": "正在运行所有单元",
"saving…": "保存中…",
"selection": "选择",
"show {{name}} in the viewport": "在视口中显示 {{name}}",
"showing {{what}}: {{reason}}": "正在显示{{what}}:{{reason}}",
"sketch": "草图",
"slot": "槽",
"solid": "实体",
"spline": "样条",
"square": "方形",
"stale": "已过期",
"starting the kernel": "正在启动内核",
"starts the part with this solid": "以这个实体作为零件的起点",
"stop": "停止",
"stop requested": "已请求停止",
"stopped": "已停止",
"subtract": "切除",
"system": "跟随系统",
"tags": "标签",
"the whole model comes back once it is fixed.": "修复后会恢复完整模型。",
"through": "通孔",
"through an edge, turned about it": "过一条边,并绕它旋转",
"through three vertices": "过三个顶点",
"trapezoidal": "梯形",
"turn": "旋转",
"unable to open the preview": "无法打开预览",
"undo": "撤销",
"unfold all": "全部展开",
"union": "合并",
"unused": "未使用",
"use picked face": "使用所选面",
"use {{body}}": "使用 {{body}}",
"used": "已使用",
"used by {{users}}": "被 {{users}} 使用",
"vert": "顶点",
"working…": "处理中…",
"workspace": "工作区",
"write to source": "写入源码",
"x direction on the face": "面上的 x 方向",
"x runs along it (on a face); the axis the plane turns about (through an edge).": "x 轴沿它(在面上);平面绕之旋转的轴(过一条边)。",
"x towards vertex": "x 轴指向顶点",
"{{count}} cells": "{{count}} 个单元",
"{{count}} cells re-evaluated in {{time}}": "{{count}} 个单元重新计算,用时 {{time}}",
"{{count}} did not complete": "{{count}} 个未完成",
"{{count}} errors": "{{count}} 个错误",
"{{count}} later steps did not run": "后面有 {{count}} 个步骤没有运行",
"{{count}} picked": "已选 {{count}} 个",
"{{count}} segments": "{{count}} 段",
"{{count}} tagged entities were split": "{{count}} 个带标签的实体被拆分了",
"{{name}}.py already exists.": "{{name}}.py 已存在。",
"{{op}} split {{tag}} into {{count}}; the tag names none of them:": "{{op}} 把 {{tag}} 拆成了 {{count}} 块;原标签不再指向其中任何一块:",
"{{steps}} failed too": "{{steps}} 也失败了",
"{{step}} cannot run": "{{step}} 无法运行",
"{{step}} failed": "{{step}} 失败",
"{{step}} was stopped": "{{step}} 已被停止",
"{{what}}, in the order clicked": "{{what}},按点击顺序"
}
+3 -2
View File
@@ -4,6 +4,7 @@
import { isSlotVisible, type FeatureRow, type FeatureState, type Slot, type SlotOption, type Spec } from "@/lib/features";
import type { SegmentOption } from "@/lib/segmented";
import { t } from "@/i18n";
export const OPERATION_SLOT = "operation";
export const TARGET_SLOT = "target";
@@ -65,10 +66,10 @@ export function targetDisplay(state: CombineState, edit: Pick<FeatureRow, "makes
if (edit) {
if (open.length > 1) return { kind: "choose" };
const name = current || "the body before it";
return { kind: "fixed", name, text: `Combined with: ${name}` };
return { kind: "fixed", name, text: `${t("Combined with:")} ${name}` };
}
if (open.length === 0) return { kind: "hidden" };
if (open.length === 1) return { kind: "fixed", name: open[0], text: `Combined with: ${open[0]}` };
if (open.length === 1) return { kind: "fixed", name: open[0], text: `${t("Combined with:")} ${open[0]}` };
return { kind: "choose" };
}
+8
View File
@@ -5,6 +5,7 @@
import type { LucideIcon } from "lucide-react";
import type { Spec } from "@/lib/features";
import { t } from "@/i18n";
export type Command = {
id: string;
@@ -335,6 +336,13 @@ function termScore(term: string, command: Command): number {
if (command.group.toLowerCase().startsWith(term)) return 40;
if (command.keywords.some((word) => word.toLowerCase().includes(term))) return 35;
if (command.group.toLowerCase().includes(term) || (command.description ?? "").toLowerCase().includes(term)) return 30;
// the names shown in the person's language (a Chinese query finds 拉伸)
const shown = t(command.label).toLowerCase();
if (shown !== label) {
if (shown.startsWith(term)) return 85;
if (shown.includes(term)) return 55;
}
if (t(command.group).toLowerCase().includes(term)) return 30;
if (term.length >= 3 && (isSubsequence(term, label) || isSubsequence(term, id.replace(/ /g, "")))) return 15;
return 0;
}
+7 -5
View File
@@ -3,6 +3,8 @@
* A cell failed, so the product was not made; the kernel previewed what the cells before it made instead (the body the
* failing feature was applied to) and says so. `null` when the model is the whole product. */
import { t } from "@/i18n";
export type FailedCell = {
/** The marimo cell id (the notebook's cells carry the same ids). */
cell: string;
@@ -45,16 +47,16 @@ export function parsePartial(value: unknown): PartialModel | null {
export function describePartial(partial: PartialModel, titles: ReadonlyMap<string, string> = new Map()): { title: string; reason: string; after: string } {
const [first, ...rest] = partial.failed;
const name = (cell: FailedCell) => titles.get(cell.cell) || cell.name;
const what = first.status === "interrupted" ? "was stopped" : first.status === "marimo-error" ? "cannot run" : "failed";
const reason = first.error ? `${name(first)} ${what}: ${firstLine(first.error)}` : `${name(first)} ${what}`;
const what = first.status === "interrupted" ? "{{step}} was stopped" : first.status === "marimo-error" ? "{{step}} cannot run" : "{{step}} failed";
const reason = first.error ? `${t(what, { step: name(first) })}: ${firstLine(first.error)}` : t(what, { step: name(first) });
const later = partial.skipped.length + rest.length;
const after = [
rest.length ? `${rest.map(name).join(", ")} failed too` : "",
later ? `${later} later ${later === 1 ? "step" : "steps"} did not run` : "",
rest.length ? t("{{steps}} failed too", { steps: rest.map(name).join(", ") }) : "",
later ? (later === 1 ? t("1 later step did not run") : t("{{count}} later steps did not run", { count: later })) : "",
]
.filter(Boolean)
.join("; ");
return { title: `The model before ${name(first)}`, reason, after };
return { title: t("The model before {{step}}", { step: name(first) }), reason, after };
}
/** An error kept to one short line (the kernel already put the SDK's errors as "Type: operation: what happened"). */
+4 -2
View File
@@ -1,4 +1,5 @@
import { useCallback, useRef, useState } from "react";
import { t } from "@/i18n";
export type LogLevel = "info" | "run" | "ok" | "error";
@@ -73,8 +74,9 @@ export function useRunLog() {
quiet.current = null;
const total = members.current.size;
if (total > 0) {
const text = `${total} ${total === 1 ? "cell" : "cells"} re-evaluated in ${seconds(Date.now() - batchStart.current)}`;
if (failures.current > 0) push("error", `${text}; ${failures.current} did not complete`);
const time = seconds(Date.now() - batchStart.current);
const text = total === 1 ? t("1 cell re-evaluated in {{time}}", { time }) : t("{{count}} cells re-evaluated in {{time}}", { count: total, time });
if (failures.current > 0) push("error", `${text}; ${t("{{count}} did not complete", { count: failures.current })}`);
else push("ok", text);
}
members.current.clear();
+1
View File
@@ -3,6 +3,7 @@ import { createRoot } from "react-dom/client";
import { App } from "./App";
import "./index.css";
import "./i18n";
import { installScrollRows } from "./lib/scroll-row";
installScrollRows();