Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

feat(ui): content-i18n — the wiki, questions, and Atlas cards speak Chinese

Martin Vogel007a46baf8f0
diff --git a/graph-ui/src/components/DashboardTab.tsx b/graph-ui/src/components/DashboardTab.tsx
index 1991d1fc9..45a0a1a81 100644
--- a/graph-ui/src/components/DashboardTab.tsx
+++ b/graph-ui/src/components/DashboardTab.tsx
@@ -285,6 +285,9 @@ export function DashboardTab({
};
}, [metrics, showMuted, mutedTick]);
+ /* TODO(content-i18n): the computed takeaway and cost sentences interpolate
+ * many numbers and stay English this pass; route them through the i18n
+ * messages mechanism in a follow-up. */
const takeaway = useMemo(() => {
if (!metrics) return null;
return complexityTakeaway(
diff --git a/graph-ui/src/components/FlowsTab.tsx b/graph-ui/src/components/FlowsTab.tsx
index 5bfe6250a..6b9471a54 100644
--- a/graph-ui/src/components/FlowsTab.tsx
+++ b/graph-ui/src/components/FlowsTab.tsx
@@ -14,6 +14,7 @@ import {
type TracePayload,
} from "../lib/atlas";
import { groupFlowsByEntry } from "../lib/flowgroup";
+import { useUiMessages } from "../lib/i18n";
import { allHopsObserved, newestObserved, observedTitle } from "../lib/observed";
import { formatGuard } from "../lib/why";
import { MetricChip } from "./MetricChip";
@@ -50,18 +51,19 @@ export function ObservedChip({
observed: ObservedCall;
onOpenWiki?: (slug: string) => void;
}) {
+ const t = useUiMessages();
return (
<span
className="text-[10px] px-1 rounded-full border border-good/50 text-good/80 font-mono shrink-0"
- title={observedTitle(observed)}
+ title={observedTitle(observed, t.observed)}
>
▶{" "}
{onOpenWiki ? (
<MetricChip slug="observed" onOpen={onOpenWiki}>
- observed
+ {t.observed.word}
</MetricChip>
) : (
- "observed"
+ t.observed.word
)}{" "}
×{observed.count}
</span>
@@ -158,6 +160,7 @@ export function FlowsTab({
onOpenSymbol,
onOpenWiki,
}: FlowsTabProps) {
+ const t = useUiMessages();
const [payload, setPayload] = useState<FlowsPayload | null>(null);
const [detail, setDetail] = useState<FlowDetail | null>(null);
const [error, setError] = useState<string | null>(null);
@@ -302,7 +305,7 @@ export function FlowsTab({
</p>
{allHopsObserved(trace.path ?? []) && (
<p className="text-[11px] text-good/70 mb-1">
- This whole path was observed in recorded runs.
+ {t.observed.allObserved}
</p>
)}
<div className="flex items-center gap-1 flex-wrap">
@@ -339,9 +342,7 @@ export function FlowsTab({
</div>
{traceNewest && (
<p className="text-[11px] text-foreground/40 mt-1.5">
- Runtime markers from recorded runs ({traceNewest.label}).
- Unmarked hops are possible, not dead — runs only cover
- what they exercised.
+ {t.observed.freshness(traceNewest.label)}
</p>
)}
</div>
@@ -522,9 +523,7 @@ export function FlowsTab({
</div>
{detailNewest && (
<p className="text-[11px] text-foreground/40 mt-3">
- Runtime markers from recorded runs ({detailNewest.label}).
- Unmarked hops are possible, not dead — runs only cover what
- they exercised.
+ {t.observed.freshness(detailNewest.label)}
</p>
)}
</div>
diff --git a/graph-ui/src/components/OverviewTab.tsx b/graph-ui/src/components/OverviewTab.tsx
index b79d57254..f5093bd1f 100644
--- a/graph-ui/src/components/OverviewTab.tsx
+++ b/graph-ui/src/components/OverviewTab.tsx
@@ -22,11 +22,12 @@ import { surprisingCouplings, suggestedQuestions } from "../lib/firstread";
import { kneeCount, findingKey, isDismissed, dismiss } from "../lib/findings";
import {
QUESTION_FAMILIES,
+ localizeQuestion,
questionStatusCounts,
type QuestionStatus,
type QuestionTab,
} from "../lib/questions";
-import { useUiMessages } from "../lib/i18n";
+import { messages, useUiLanguage } from "../lib/i18n";
import { AddToPromptButton } from "./PromptBasket";
import type { RegionsPayload } from "../lib/types";
@@ -150,7 +151,8 @@ function StatusGlyph({ status }: { status: QuestionStatus }) {
* honest scorecard: answered, partially answered, or not answered yet.
* Collapsed by default; the header summary is derived from the data. */
function QuestionIndex({ onOpenTab }: { onOpenTab: (tab: QuestionTab) => void }) {
- const t = useUiMessages();
+ const lang = useUiLanguage();
+ const t = messages[lang];
const [open, setOpen] = useState(() => {
try {
return localStorage.getItem("cbm-questions-open") === "1";
@@ -200,6 +202,7 @@ function QuestionIndex({ onOpenTab }: { onOpenTab: (tab: QuestionTab) => void })
<div className="border-t border-border/30 py-1">
{QUESTION_FAMILIES.map((family) => {
const tab = family.tab;
+ const loc = localizeQuestion(family, lang);
const inner = (clickable: boolean) => (
<>
<span className="flex items-center gap-1.5 w-[76px] shrink-0 pt-[2px]">
@@ -216,13 +219,13 @@ function QuestionIndex({ onOpenTab }: { onOpenTab: (tab: QuestionTab) => void })
: ""
}`}
>
- {family.question}
+ {loc.question}
</span>
- {(family.hint || family.gap) && (
+ {(loc.hint || loc.gap) && (
<span className="block text-[12px] text-foreground/40 mt-0.5">
- {family.hint}
- {family.hint && family.gap && " · "}
- {family.gap && `${t.questions.missingPrefix} ${family.gap}`}
+ {loc.hint}
+ {loc.hint && loc.gap && " · "}
+ {loc.gap && `${t.questions.missingPrefix} ${loc.gap}`}
</span>
)}
</span>
diff --git a/graph-ui/src/components/SymbolTab.tsx b/graph-ui/src/components/SymbolTab.tsx
index 2feea8fac..7d87996b0 100644
--- a/graph-ui/src/components/SymbolTab.tsx
+++ b/graph-ui/src/components/SymbolTab.tsx
@@ -12,6 +12,7 @@ import {
type SymbolBundle,
type SymbolRef,
} from "../lib/atlas";
+import { useUiMessages } from "../lib/i18n";
import { fetchImpact, impactSentence, type ImpactPayload } from "../lib/impact";
import {
commitUrl,
@@ -202,6 +203,7 @@ export function SymbolTab({
onOpenRegion,
onOpenWiki,
}: SymbolTabProps) {
+ const t = useUiMessages();
const [bundle, setBundle] = useState<SymbolBundle | null>(null);
const [error, setError] = useState<string | null>(null);
const [limit, setLimit] = useState(50);
@@ -484,13 +486,15 @@ export function SymbolTab({
<div className="bg-card border border-border/40 rounded-md p-4 mb-4">
<div className="flex items-baseline gap-2 mb-2">
<p className="text-[12px] uppercase tracking-widest text-foreground/45">
- If you change this
+ {t.impact.heading}
</p>
<span className="text-[12px] text-foreground/40">
<MetricChip slug="blast-radius" onOpen={onOpenWiki} />
</span>
</div>
- <p className="text-[14px] text-foreground/85">{impactSentence(impact)}</p>
+ <p className="text-[14px] text-foreground/85">
+ {impactSentence(impact, t.impact)}
+ </p>
{impactTiers && (
<p className="text-[12px] text-foreground/40 mt-1">{impactTiers}</p>
)}
@@ -519,7 +523,7 @@ export function SymbolTab({
{impact.tests.count > 0 ? (
<div className="mt-3">
<p className="text-[12px] uppercase tracking-widest text-foreground/45 mb-1">
- Run these first
+ {t.impact.runTheseFirst}
</p>
<div className="space-y-px">
{impact.tests.nearest.map((test) => (
@@ -549,13 +553,11 @@ export function SymbolTab({
</div>
) : (
<p className="text-[13px] text-amber-300/80 mt-3">
- ⚠ No test reaches this symbol — nothing will catch a regression
- here automatically.
+ {t.impact.noTestReaches}
</p>
)}
<p className="text-[12px] text-foreground/35 mt-3">
- Static CALLS edges only — dynamic dispatch and reflection are not
- counted; treat the count as a floor.
+ {t.impact.basisFootnote}
</p>
</div>
)}
@@ -644,12 +646,11 @@ export function SymbolTab({
{canTrace && (
<div className="bg-card border border-border/50 rounded-md p-4 mb-4">
<p className="text-[12px] uppercase tracking-widest text-foreground/40 mb-2">
- Why is this here?
+ {t.history.whyHere}
</p>
{node.docstring && (
<p className="text-[12px] text-foreground/40 mb-2">
- The docstring above is the stated intent; below is the recorded
- history.
+ {t.history.docstringIntro}
</p>
)}
{!history && (
@@ -658,22 +659,22 @@ export function SymbolTab({
disabled={historyLoading}
className="px-2.5 py-1 rounded-md bg-primary/15 text-primary text-[13px] font-medium hover:bg-primary/25 transition-colors disabled:opacity-40"
>
- Trace this symbol's history
+ {t.history.trace}
</button>
)}
{historyLoading && (
<p className="text-[13px] text-foreground/40 mt-2">
- Reading git history…
+ {t.history.reading}
</p>
)}
{historyError && (
<p className="text-[13px] text-foreground/40 mt-2">
- History unavailable: {historyError}
+ {t.history.unavailable(historyError)}
</p>
)}
{history && !history.available && (
<p className="text-[13px] text-foreground/40">
- No git history is readable for this symbol's file.
+ {t.history.noneReadable}
</p>
)}
{history?.available && (
@@ -689,19 +690,18 @@ export function SymbolTab({
</div>
{(history.commits ?? []).length === 0 && (
<p className="text-[13px] text-foreground/40">
- No commits recorded for this line range.
+ {t.history.noneForRange}
</p>
)}
{history.truncated && (
<p className="text-[12px] text-foreground/40 mt-1">
- showing {history.max_commits} (capped)
+ {t.history.capped(history.max_commits)}
</p>
)}
</>
)}
<p className="text-[12px] text-foreground/35 mt-3">
- History follows this symbol's line range through renames (git log
- -L). PR and issue links open the forge — titles are not fetched.
+ {t.history.footnote}
</p>
</div>
)}
diff --git a/graph-ui/src/components/WikiHoverCard.tsx b/graph-ui/src/components/WikiHoverCard.tsx
index 065087f31..057cb50eb 100644
--- a/graph-ui/src/components/WikiHoverCard.tsx
+++ b/graph-ui/src/components/WikiHoverCard.tsx
@@ -18,8 +18,8 @@ import {
} from "react";
import { createPortal } from "react-dom";
import { loadTooltipDelayMs } from "../lib/density";
-import { useUiMessages } from "../lib/i18n";
-import { wikiEntry } from "../wiki/entries";
+import { messages, useUiLanguage } from "../lib/i18n";
+import { localizeEntry, wikiEntry } from "../wiki/entries";
import { TIER_TONE } from "./wikiTier";
/* Leaving the chip closes after this grace — long enough to reach the card,
@@ -43,7 +43,8 @@ export function WikiHoverCard({ slug, anchorRef, delayMs }: WikiHoverCardProps)
const showTimer = useRef<number | null>(null);
const hideTimer = useRef<number | null>(null);
const cardId = useId();
- const t = useUiMessages();
+ const lang = useUiLanguage();
+ const t = messages[lang];
const entry = wikiEntry(slug);
const open = pos !== null;
@@ -178,7 +179,9 @@ export function WikiHoverCard({ slug, anchorRef, delayMs }: WikiHoverCardProps)
{entry.tier}
</span>
</div>
- <p className="text-foreground/70 leading-relaxed">{entry.sentence}</p>
+ <p className="text-foreground/70 leading-relaxed">
+ {localizeEntry(entry, lang).sentence}
+ </p>
<p className="text-foreground/35 mt-1 text-[12px]">{t.wiki.clickForMore}</p>
</div>,
document.body,
diff --git a/graph-ui/src/components/WikiPanel.tsx b/graph-ui/src/components/WikiPanel.tsx
index 4a5b24bef..0eeff29ec 100644
--- a/graph-ui/src/components/WikiPanel.tsx
+++ b/graph-ui/src/components/WikiPanel.tsx
@@ -6,8 +6,8 @@
* "Refused" entries render muted — they document what Atlas won't show. */
import { useEffect, useState } from "react";
import { ScrollArea } from "@/components/ui/scroll-area";
-import { useUiMessages } from "../lib/i18n";
-import { wikiEntry } from "../wiki/entries";
+import { messages, useUiLanguage } from "../lib/i18n";
+import { localizeEntry, wikiEntry } from "../wiki/entries";
import { MetricChip } from "./MetricChip";
import { TIER_TONE } from "./wikiTier";
@@ -26,7 +26,8 @@ function SectionHeading({ children }: { children: string }) {
}
export function WikiPanel({ slug, onClose, onNavigate }: WikiPanelProps) {
- const t = useUiMessages();
+ const lang = useUiLanguage();
+ const t = messages[lang];
/* The navigation stack. The host owns the current slug; every push goes
* through onNavigate and lands here via the prop effect, so chips outside
* and inside the panel behave identically. */
@@ -56,6 +57,8 @@ export function WikiPanel({ slug, onClose, onNavigate }: WikiPanelProps) {
};
const entry = wikiEntry(slug);
+ /* zh content with per-field English fallback; the term stays English. */
+ const view = entry ? localizeEntry(entry, lang) : undefined;
const refused = entry?.tier === "refused";
return (
@@ -97,14 +100,15 @@ export function WikiPanel({ slug, onClose, onNavigate }: WikiPanelProps) {
</button>
</div>
- {!entry ? (
+ {!entry || !view ? (
<p className="text-[13px] text-foreground/40 px-4 py-6">
No wiki entry for “{slug}”.
</p>
) : (
<ScrollArea className="flex-1 min-h-0">
<div className="px-4 py-4">
- {/* Term + tier */}
+ {/* Term + gloss + tier — the term is English-canonical; the zh
+ * locale glosses it rather than replacing it. */}
<div className="flex items-center gap-2.5 flex-wrap mb-2">
<h3
className={`text-[17px] font-semibold ${
@@ -113,6 +117,9 @@ export function WikiPanel({ slug, onClose, onNavigate }: WikiPanelProps) {
>
{entry.term}
</h3>
+ {view.gloss && (
+ <span className="text-[13px] text-foreground/55">{view.gloss}</span>
+ )}
<span
className={`px-2 py-0.5 rounded-md text-[12px] font-medium ${TIER_TONE[entry.tier]}`}
>
@@ -126,27 +133,27 @@ export function WikiPanel({ slug, onClose, onNavigate }: WikiPanelProps) {
refused ? "text-foreground/50" : "text-foreground/75"
}`}
>
- {entry.sentence}
+ {view.sentence}
</p>
- {entry.why && (
+ {view.why && (
<div className="mt-4">
<SectionHeading>{t.wiki.whyMatters}</SectionHeading>
<p className="text-[13px] text-foreground/60 leading-relaxed max-w-[60ch]">
- {entry.why}
+ {view.why}
</p>
</div>
)}
- {(entry.computedParts || entry.caps) && (
+ {(view.computedParts || view.caps) && (
<div className="mt-4">
<SectionHeading>{t.wiki.howComputed}</SectionHeading>
- {(entry.computedParts ?? []).map((part) => (
+ {(view.computedParts ?? []).map((part) => (
<p key={part} className="text-[13px] text-foreground/60 py-[2px]">
· {part}
</p>
))}
- {(entry.caps ?? []).map((cap) => (
+ {(view.caps ?? []).map((cap) => (
<p key={cap} className="text-[13px] text-amber-300/70 py-[2px]">
⚠ {cap}
</p>
@@ -154,19 +161,19 @@ export function WikiPanel({ slug, onClose, onNavigate }: WikiPanelProps) {
</div>
)}
- {entry.notCovered && (
+ {view.notCovered && (
<div className="mt-4">
<SectionHeading>{t.wiki.notCovered}</SectionHeading>
<p className="text-[13px] text-foreground/60 leading-relaxed max-w-[60ch]">
- {entry.notCovered}
+ {view.notCovered}
</p>
</div>
)}
- {entry.appearsIn.length > 0 && (
+ {view.appearsIn.length > 0 && (
<div className="mt-4">
<SectionHeading>{t.wiki.whereAppears}</SectionHeading>
- {entry.appearsIn.map((place) => (
+ {view.appearsIn.map((place) => (
<p key={place} className="text-[13px] text-foreground/60 py-[2px]">
{place}
</p>
diff --git a/graph-ui/src/components/WikiPanel.zh.test.tsx b/graph-ui/src/components/WikiPanel.zh.test.tsx
new file mode 100644
index 000000000..faab10cfa
--- /dev/null
+++ b/graph-ui/src/components/WikiPanel.zh.test.tsx
@@ -0,0 +1,34 @@
+/* @vitest-environment jsdom */
+/* The zh locale reaches the panel exactly as it does in production: the
+ * /api/ui-config override that detectLanguage honours (see i18n.test.ts).
+ * The i18n module caches the resolved language per module registry, so the
+ * zh render lives in its own file — WikiPanel.test.tsx stays English. */
+import "@testing-library/jest-dom/vitest";
+import { render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { wikiEntry } from "../wiki/entries";
+import { WikiPanel } from "./WikiPanel";
+
+describe("WikiPanel (zh locale)", () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ it("shows the zh sentence and gloss under the English-canonical term", async () => {
+ vi.stubGlobal(
+ "fetch",
+ vi.fn().mockResolvedValue({ json: () => Promise.resolve({ lang: "zh" }) }),
+ );
+ render(<WikiPanel slug="hotspot" onClose={() => {}} onNavigate={() => {}} />);
+
+ const entry = wikiEntry("hotspot")!;
+ expect(await screen.findByText(entry.zh!.sentence!)).toBeInTheDocument();
+ /* The term stays English-canonical; the zh gloss rides beside it. */
+ expect(screen.getByRole("heading", { name: "hotspot" })).toBeInTheDocument();
+ expect(screen.getByText(entry.zh!.gloss!)).toBeInTheDocument();
+ /* Section chrome comes from the zh catalog; caps render translated. */
+ expect(screen.getByText("为什么重要")).toBeInTheDocument();
+ expect(screen.getByText(entry.zh!.why!)).toBeInTheDocument();
+ expect(screen.getByText(`⚠ ${entry.zh!.caps![0]}`)).toBeInTheDocument();
+ });
+});
diff --git a/graph-ui/src/lib/i18n.ts b/graph-ui/src/lib/i18n.ts
index 74c0ae36b..781f06b05 100644
--- a/graph-ui/src/lib/i18n.ts
+++ b/graph-ui/src/lib/i18n.ts
@@ -89,6 +89,39 @@ export const messages = {
summary: (answers: number, partial: number, lacks: number) =>
`${answers} answered · ${partial} partial · ${lacks} not yet`,
},
+ impact: {
+ heading: "If you change this",
+ nothingCalls:
+ "Nothing recorded calls this — changes here surface only where it is referenced dynamically.",
+ sentence: (reachable: number, callableTotal: number, regionTotal: number) =>
+ `${reachable.toLocaleString("en-US")} of ${callableTotal.toLocaleString("en-US")} callables can reach this — ${regionTotal.toLocaleString("en-US")} region${regionTotal === 1 ? "" : "s"} could notice.`,
+ cappedSuffix: " (walk capped — the true count is higher)",
+ runTheseFirst: "Run these first",
+ noTestReaches:
+ "⚠ No test reaches this symbol — nothing will catch a regression here automatically.",
+ basisFootnote:
+ "Static CALLS edges only — dynamic dispatch and reflection are not counted; treat the count as a floor.",
+ },
+ history: {
+ whyHere: "Why is this here?",
+ docstringIntro:
+ "The docstring above is the stated intent; below is the recorded history.",
+ trace: "Trace this symbol's history",
+ reading: "Reading git history…",
+ unavailable: (reason: string) => `History unavailable: ${reason}`,
+ noneReadable: "No git history is readable for this symbol's file.",
+ noneForRange: "No commits recorded for this line range.",
+ capped: (max: number) => `showing ${max} (capped)`,
+ footnote:
+ "History follows this symbol's line range through renames (git log -L). PR and issue links open the forge — titles are not fetched.",
+ },
+ observed: {
+ word: "observed",
+ allObserved: "This whole path was observed in recorded runs.",
+ freshness: (label: string) =>
+ `Runtime markers from recorded runs (${label}). Unmarked hops are possible, not dead — runs only cover what they exercised.`,
+ title: (label: string, date: string) => `ran in ${label} · last ${date}`,
+ },
control: {
panel: "Control Panel",
totalCpu: "Total CPU",
@@ -189,6 +222,38 @@ export const messages = {
summary: (answers: number, partial: number, lacks: number) =>
`${answers} 已回答 · ${partial} 部分 · ${lacks} 暂缺`,
},
+ impact: {
+ heading: "如果你改动这里",
+ nothingCalls:
+ "没有任何已记录的调用指向这里——改动只会在动态引用它的地方显现。",
+ sentence: (reachable: number, callableTotal: number, regionTotal: number) =>
+ `全仓库 ${callableTotal.toLocaleString("en-US")} 个可调用符号中,有 ${reachable.toLocaleString("en-US")} 个能到达这里——${regionTotal.toLocaleString("en-US")} 个区域可能察觉。`,
+ cappedSuffix: "(遍历已达上限——真实数量更高)",
+ runTheseFirst: "先跑这些测试",
+ noTestReaches:
+ "⚠ 没有任何测试到达这个符号——出了回归不会被自动发现。",
+ basisFootnote:
+ "仅统计静态 CALLS 边——动态分发与反射不计入;请把数字当作下限。",
+ },
+ history: {
+ whyHere: "为什么会有这段代码?",
+ docstringIntro: "上方的文档注释是声明的意图;下面是实际记录的历史。",
+ trace: "追溯这个符号的历史",
+ reading: "正在读取 git 历史…",
+ unavailable: (reason: string) => `历史不可用:${reason}`,
+ noneReadable: "这个符号所在的文件没有可读的 git 历史。",
+ noneForRange: "这段行范围没有记录到任何提交。",
+ capped: (max: number) => `仅显示 ${max} 条(已达上限)`,
+ footnote:
+ "历史沿这个符号自身的行范围追踪,可跨重命名(git log -L)。PR 与 issue 链接指向代码托管平台——标题不会被抓取。",
+ },
+ observed: {
+ word: "已观测",
+ allObserved: "这条路径整体都在录制的运行中被观测到。",
+ freshness: (label: string) =>
+ `运行时标记来自录制的运行(${label})。未标记的跳步只是可能执行,不代表死代码——一次运行只覆盖它实际执行到的部分。`,
+ title: (label: string, date: string) => `曾在 ${label} 中执行 · 最近 ${date}`,
+ },
control: {
panel: "控制面板",
totalCpu: "总 CPU",
@@ -254,7 +319,10 @@ function loadUiLanguage(): Promise<UiLanguage> {
return languageRequest;
}
-export function useUiMessages(): UiMessages {
+/* The active language itself — for content that localizes outside the
+ * message catalog (wiki entries, question families carry co-located zh
+ * fields with per-field English fallback). */
+export function useUiLanguage(): UiLanguage {
const [lang, setLang] = useState<UiLanguage>(cachedLanguage);
useEffect(() => {
@@ -269,5 +337,9 @@ export function useUiMessages(): UiMessages {
};
}, []);
- return messages[lang];
+ return lang;
+}
+
+export function useUiMessages(): UiMessages {
+ return messages[useUiLanguage()];
}
diff --git a/graph-ui/src/lib/impact.test.ts b/graph-ui/src/lib/impact.test.ts
index 1ad0f4f60..b19e9b9bc 100644
--- a/graph-ui/src/lib/impact.test.ts
+++ b/graph-ui/src/lib/impact.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest";
+import { messages } from "./i18n";
import { impactSentence, type ImpactPayload } from "./impact";
const payload = (overrides: Partial<ImpactPayload> = {}): ImpactPayload => ({
@@ -47,4 +48,13 @@ describe("impactSentence", () => {
"Nothing recorded calls this — changes here surface only where it is referenced dynamically.",
);
});
+
+ it("speaks the zh catalog with the same numbers when its messages are passed", () => {
+ expect(impactSentence(payload(), messages.zh.impact)).toBe(
+ "全仓库 4,200 个可调用符号中,有 210 个能到达这里——3 个区域可能察觉。",
+ );
+ expect(impactSentence(payload({ truncated: true }), messages.zh.impact)).toContain(
+ "(遍历已达上限——真实数量更高)",
+ );
+ });
});
diff --git a/graph-ui/src/lib/impact.ts b/graph-ui/src/lib/impact.ts
index cdbde6ab6..211cd1c92 100644
--- a/graph-ui/src/lib/impact.ts
+++ b/graph-ui/src/lib/impact.ts
@@ -2,6 +2,7 @@
* notice a change to one symbol, at what distance, in which regions, and
* which tests reach it. Counts are floors: static CALLS edges only, and
* the walk is capped in depth and volume. */
+import { messages, type UiMessages } from "./i18n";
import { fetchJsonFrom } from "./whyfetch";
export interface ImpactNode {
@@ -50,13 +51,14 @@ export async function fetchImpact(
/* The headline sentence. Region count includes the rows the payload capped
* away (regions_more); a capped walk says so — the count is then a floor
- * of a floor. */
-export function impactSentence(payload: ImpactPayload): string {
- if (payload.reachable === 0)
- return "Nothing recorded calls this — changes here surface only where it is referenced dynamically.";
+ * of a floor. Pass the active locale's impact messages to localize. */
+export function impactSentence(
+ payload: ImpactPayload,
+ m: UiMessages["impact"] = messages.en.impact,
+): string {
+ if (payload.reachable === 0) return m.nothingCalls;
const regionTotal = payload.regions.length + payload.regions_more;
- const sentence = `${payload.reachable.toLocaleString("en-US")} of ${payload.callable_total.toLocaleString("en-US")} callables can reach this — ${regionTotal.toLocaleString("en-US")} region${regionTotal === 1 ? "" : "s"} could notice.`;
- if (payload.truncated || payload.depth_capped)
- return `${sentence} (walk capped — the true count is higher)`;
+ const sentence = m.sentence(payload.reachable, payload.callable_total, regionTotal);
+ if (payload.truncated || payload.depth_capped) return `${sentence}${m.cappedSuffix}`;
return sentence;
}
diff --git a/graph-ui/src/lib/observed.test.ts b/graph-ui/src/lib/observed.test.ts
index b72e20d11..33c94970e 100644
--- a/graph-ui/src/lib/observed.test.ts
+++ b/graph-ui/src/lib/observed.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest";
+import { messages } from "./i18n";
import { allHopsObserved, newestObserved, observedTitle } from "./observed";
const obs = (label: string, last_seen: string, count = 1) => ({
@@ -58,4 +59,10 @@ describe("observedTitle", () => {
"ran in pytest 2026-08-27 · last 2026-08-27",
);
});
+
+ it("speaks the zh catalog when its messages are passed", () => {
+ expect(
+ observedTitle(obs("pytest 2026-08-27", "2026-08-27T14:12:00Z", 4), messages.zh.observed),
+ ).toBe("曾在 pytest 2026-08-27 中执行 · 最近 2026-08-27");
+ });
});
diff --git a/graph-ui/src/lib/observed.ts b/graph-ui/src/lib/observed.ts
index 374a079a0..66dfba5d9 100644
--- a/graph-ui/src/lib/observed.ts
+++ b/graph-ui/src/lib/observed.ts
@@ -3,6 +3,7 @@
* recorded run; absence means "never recorded", which must never be read
* as dead or unused — a run only covers what it exercised. */
import type { ObservedCall } from "./atlas";
+import { messages, type UiMessages } from "./i18n";
/* True when every hop beyond the first is observed (the first entry is the
* origin, not a call). False when there is no hop to judge. */
@@ -25,7 +26,11 @@ export function newestObserved(
return newest;
}
-/* Title text for the marker chip: "ran in pytest 2026-08-27 · last 2026-08-27". */
-export function observedTitle(observed: ObservedCall): string {
- return `ran in ${observed.label} · last ${observed.last_seen.slice(0, 10)}`;
+/* Title text for the marker chip: "ran in pytest 2026-08-27 · last 2026-08-27".
+ * Pass the active locale's observed messages to localize. */
+export function observedTitle(
+ observed: ObservedCall,
+ m: UiMessages["observed"] = messages.en.observed,
+): string {
+ return m.title(observed.label, observed.last_seen.slice(0, 10));
}
diff --git a/graph-ui/src/lib/questions.test.ts b/graph-ui/src/lib/questions.test.ts
index cd18a5789..b680c2817 100644
--- a/graph-ui/src/lib/questions.test.ts
+++ b/graph-ui/src/lib/questions.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { QUESTION_FAMILIES, questionStatusCounts } from "./questions";
+import { QUESTION_FAMILIES, localizeQuestion, questionStatusCounts } from "./questions";
describe("QUESTION_FAMILIES", () => {
it("carries exactly 18 families with unique ids F1..F18", () => {
@@ -41,4 +41,26 @@ describe("QUESTION_FAMILIES", () => {
);
expect(questionStatusCounts([])).toEqual({ answers: 0, partial: 0, lacks: 0 });
});
+
+ it("phrases every family as a question in Chinese too", () => {
+ for (const family of QUESTION_FAMILIES) {
+ expect(family.zh?.question?.trim(), family.id).toBeTruthy();
+ expect(/[??]$/.test(family.zh?.question ?? ""), family.id).toBe(true);
+ }
+ });
+
+ it("mirrors every English hint and gap in Chinese", () => {
+ for (const family of QUESTION_FAMILIES) {
+ if (family.hint) expect(family.zh?.hint?.trim(), family.id).toBeTruthy();
+ if (family.gap) expect(family.zh?.gap?.trim(), family.id).toBeTruthy();
+ }
+ });
+
+ it("localizeQuestion swaps content for zh and falls back to English", () => {
+ const family = QUESTION_FAMILIES[0];
+ expect(localizeQuestion(family, "zh").question).toBe(family.zh!.question);
+ expect(localizeQuestion(family, "en").question).toBe(family.question);
+ const bare = { id: "X", question: "Plain?", status: "answers" as const };
+ expect(localizeQuestion(bare, "zh").question).toBe("Plain?");
+ });
});
diff --git a/graph-ui/src/lib/questions.ts b/graph-ui/src/lib/questions.ts
index 78bfca76f..f642cac0a 100644
--- a/graph-ui/src/lib/questions.ts
+++ b/graph-ui/src/lib/questions.ts
@@ -2,9 +2,10 @@
* developer-information-needs research reduces to 18 question families;
* this module says, per family, whether Atlas answers it, answers it
* partially, or does not answer it yet. Honesty about the gaps is a
- * deliberate product feature — the wording is not softened.
- * The question/hint/gap strings stay English for now: content-i18n is a
- * separate queued pass (UI chrome around them is translated in i18n.ts). */
+ * deliberate product feature — the wording is not softened, in either
+ * language. Chinese content lives co-located per family (zh) with
+ * per-field English fallback; UI chrome around it is in i18n.ts. */
+import type { UiLanguage } from "./i18n";
import type { TabId } from "./types";
export type QuestionStatus = "answers" | "partial" | "lacks";
@@ -24,6 +25,8 @@ export interface QuestionFamily {
hint?: string;
/* What's missing — required for partial and lacks. */
gap?: string;
+ /* Simplified-Chinese content; absent fields fall back to English. */
+ zh?: { question?: string; hint?: string; gap?: string };
}
export const QUESTION_FAMILIES: QuestionFamily[] = [
@@ -33,12 +36,20 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "answers",
tab: "graph",
hint: "Galaxy + Modules + ⌘K search; scent shows where a term concentrates",
+ zh: {
+ question: "做 X 的代码在哪里?",
+ hint: "星系 + 模块 + ⌘K 搜索;scent 显示搜索词聚集在哪里",
+ },
},
{
id: "F2",
question: "What calls this — and what does it call?",
status: "answers",
hint: "Open any symbol (⌘K) — callers and callees with resolution confidence",
+ zh: {
+ question: "谁调用它——它又调用谁?",
+ hint: "打开任意符号(⌘K)——调用者与被调用者,附解析置信度",
+ },
},
{
id: "F3",
@@ -46,6 +57,10 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "answers",
tab: "changes",
hint: "Changes tab for the current diff; every symbol page answers it hypothetically under 'If you change this'",
+ zh: {
+ question: "改了这里,什么会坏——必须重测什么?",
+ hint: "变更页看当前 diff;每个符号页在“如果你改动这里”下做假设性回答",
+ },
},
{
id: "F4",
@@ -53,6 +68,10 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "partial",
tab: "dashboard",
gap: "Dead candidates list what has no recorded callers; the caveats you must check first are in the wiki entry",
+ zh: {
+ question: "这段代码死了吗?能安全删掉吗?",
+ gap: "疑似死代码列出没有已记录调用者的符号;删除前必须核对的注意事项在 wiki 词条里",
+ },
},
{
id: "F5",
@@ -61,12 +80,21 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
tab: "flows",
hint: "Flows tab — ▶ observed markers on trace hops and flow steps show what actually ran",
gap: "Flows and traces now mark observed vs possible hops from ingested runtime traces; automatic trace capture and failure reproduction are not built",
+ zh: {
+ question: "这个行为是哪段代码引起的?",
+ hint: "流程页——追踪跳步与流程步骤上的 ▶ 已观测标记显示真实运行过什么",
+ gap: "流程与追踪现在能依据摄入的运行时追踪区分已观测与可能的跳步;自动抓取追踪与失败复现尚未构建",
+ },
},
{
id: "F6",
question: "When does this actually run, and under what conditions?",
status: "answers",
hint: "Open any symbol — the trigger tree shows guards, dispatch, and what it triggers",
+ zh: {
+ question: "它实际何时运行,在什么条件下?",
+ hint: "打开任意符号——触发树展示守卫、分发方式以及它会触发什么",
+ },
},
{
id: "F7",
@@ -74,12 +102,21 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "partial",
hint: "Symbol view: docs, ADR panel, file history, and 'Why is this here?' traces a symbol's own git history",
gap: "Symbol-level history with linked commits and PR/issue refs is here; PR/issue titles and ADR-to-symbol links are not fetched or joined yet",
+ zh: {
+ question: "当初为什么这么设计?",
+ hint: "符号页:文档、ADR 面板、文件历史;“为什么会有这段代码?”追溯符号自身的 git 历史",
+ gap: "带提交与 PR/issue 引用链接的符号级历史已就绪;PR/issue 标题与 ADR 到符号的关联尚未抓取或连接",
+ },
},
{
id: "F8",
question: "Did I follow this codebase's conventions?",
status: "lacks",
gap: "Conventions conformance is not derived yet — planned",
+ zh: {
+ question: "我遵守这个代码库的约定了吗?",
+ gap: "约定符合度尚未推导——已列入计划",
+ },
},
{
id: "F9",
@@ -88,6 +125,11 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
tab: "dashboard",
hint: "Tested symbols card; per-symbol 'Tested by'",
gap: "TESTS-edge reach is shown per symbol; change→test selection is planned",
+ zh: {
+ question: "哪些测试覆盖它?",
+ hint: "已测符号卡片;每个符号页的 Tested by",
+ gap: "按符号展示 TESTS 边触达;变更→测试选择在计划中",
+ },
},
{
id: "F10",
@@ -95,6 +137,10 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "answers",
tab: "dashboard",
hint: "Churn × complexity hero with the knee-based head and cost sentence",
+ zh: {
+ question: "风险在哪里——我们该先修什么?",
+ hint: "变更频率 × 复杂度英雄区,带基于拐点的头部与成本句",
+ },
},
{
id: "F11",
@@ -102,6 +148,10 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "answers",
tab: "overview",
hint: "Regions, boundary spanners, unusually-coupled pairs",
+ zh: {
+ question: "有哪些组件——边界被遵守了吗?",
+ hint: "区域、跨界符号、异常耦合的区域对",
+ },
},
{
id: "F12",
@@ -109,6 +159,11 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "partial",
hint: "Symbol view: file history and co-change",
gap: "File-granular only; symbol-level evolution is not tracked",
+ zh: {
+ question: "这里改过什么,什么会随它一起改?",
+ hint: "符号页:文件历史与共同变更",
+ gap: "只到文件粒度;符号级演化未被跟踪",
+ },
},
{
id: "F13",
@@ -116,12 +171,21 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "partial",
hint: "Symbol view: file history authors",
gap: "Top authors with evidence per file; a dedicated who-can-help view is planned — never a leaderboard",
+ zh: {
+ question: "谁了解这段代码——我该问谁?",
+ hint: "符号页:文件历史作者",
+ gap: "按文件给出带证据的主要作者;专门的“可求助的人”视图在计划中——绝不做排行榜",
+ },
},
{
id: "F14",
question: "Does this dependency upgrade reach my code — what breaks?",
status: "lacks",
gap: "External dependency reachability is not modelled yet — planned",
+ zh: {
+ question: "这次依赖升级会波及我的代码吗——什么会坏?",
+ gap: "外部依赖可达性尚未建模——已列入计划",
+ },
},
{
id: "F15",
@@ -129,6 +193,11 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
status: "partial",
hint: "Symbol view: snippets and near-clones",
gap: "Deliberately not invested — LLMs answer idiom questions well; Atlas shows real call sites and near-clones instead",
+ zh: {
+ question: "这个 API 的惯用法是什么?",
+ hint: "符号页:代码片段与近似克隆",
+ gap: "有意不投入——LLM 很擅长回答惯用法问题;Atlas 转而展示真实调用点与近似克隆",
+ },
},
{
id: "F16",
@@ -137,18 +206,31 @@ export const QUESTION_FAMILIES: QuestionFamily[] = [
tab: "overview",
hint: "Needs attention (Overview) + Changes risk",
gap: "Needs-attention ranks code-side difficulty; there is no issue-tracker join",
+ zh: {
+ question: "这个 bug 报告靠谱吗——修起来有多难?",
+ hint: "需要关注(总览)+ 变更页风险",
+ gap: "“需要关注”只排代码侧的难度;没有 issue 跟踪器关联",
+ },
},
{
id: "F17",
question: "What did the agent touch — and what did it not look at?",
status: "lacks",
gap: "Agent-diff provenance is not built yet — planned",
+ zh: {
+ question: "智能体动了什么——它没看什么?",
+ gap: "智能体 diff 溯源尚未构建——已列入计划",
+ },
},
{
id: "F18",
question: "What do I hand my agent so it doesn't guess?",
status: "answers",
hint: "The Prompt composer collects cited evidence; flows copy as mermaid; the handout is one click",
+ zh: {
+ question: "我该把什么交给智能体,让它不用猜?",
+ hint: "Prompt 合成器收集带引用的证据;流程可复制为 mermaid;讲义一键生成",
+ },
},
];
@@ -160,3 +242,17 @@ export function questionStatusCounts(
for (const family of families) counts[family.status] += 1;
return counts;
}
+
+/* One family as one locale sees it — zh fields when the locale is zh and
+ * the field exists, English fallback field-by-field. */
+export function localizeQuestion(
+ family: QuestionFamily,
+ lang: UiLanguage,
+): Pick<QuestionFamily, "question" | "hint" | "gap"> {
+ if (lang !== "zh" || !family.zh) return family;
+ return {
+ question: family.zh.question ?? family.question,
+ hint: family.zh.hint ?? family.hint,
+ gap: family.zh.gap ?? family.gap,
+ };
+}
diff --git a/graph-ui/src/wiki/entries.test.ts b/graph-ui/src/wiki/entries.test.ts
index 1787a6630..f5fc4559f 100644
--- a/graph-ui/src/wiki/entries.test.ts
+++ b/graph-ui/src/wiki/entries.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { WIKI_ENTRIES, wikiEntry, wikiEntryById } from "./entries";
+import { WIKI_ENTRIES, localizeEntry, wikiEntry, wikiEntryById } from "./entries";
describe("wiki entries", () => {
it("every sentence is present and tooltip-sized (≤30 words)", () => {
@@ -49,4 +49,38 @@ describe("wiki entries", () => {
expect(wikiEntry("no-such-metric")).toBeUndefined();
expect(wikiEntryById("M-NO-SUCH")).toBeUndefined();
});
+
+ it("every entry carries zh content — sentence + notCovered, or + why when refused", () => {
+ for (const entry of WIKI_ENTRIES) {
+ expect(entry.zh?.sentence?.trim(), entry.slug).toBeTruthy();
+ if (entry.tier === "refused") {
+ expect(entry.zh?.why?.trim(), entry.slug).toBeTruthy();
+ } else {
+ expect(entry.zh?.notCovered?.trim(), entry.slug).toBeTruthy();
+ }
+ }
+ });
+
+ it("every zh sentence stays tooltip-sized (≤45 characters — zh is denser)", () => {
+ for (const entry of WIKI_ENTRIES) {
+ if (!entry.zh?.sentence) continue;
+ expect(
+ [...entry.zh.sentence.trim()].length,
+ `${entry.slug} zh sentence exceeds 45 characters`,
+ ).toBeLessThanOrEqual(45);
+ }
+ });
+
+ it("localizeEntry swaps content per field and keeps the term English", () => {
+ const entry = wikiEntry("hotspot")!;
+ const zh = localizeEntry(entry, "zh");
+ expect(zh.term).toBe("hotspot");
+ expect(zh.sentence).toBe(entry.zh!.sentence);
+ expect(zh.gloss).toBe(entry.zh!.gloss);
+ /* computedParts has no zh variant — the English falls through. */
+ expect(zh.computedParts).toEqual(entry.computedParts);
+ const en = localizeEntry(entry, "en");
+ expect(en.sentence).toBe(entry.sentence);
+ expect(en.gloss).toBeUndefined();
+ });
});
diff --git a/graph-ui/src/wiki/entries.ts b/graph-ui/src/wiki/entries.ts
index 798c1300e..a87cb4f41 100644
--- a/graph-ui/src/wiki/entries.ts
+++ b/graph-ui/src/wiki/entries.ts
@@ -2,7 +2,9 @@
* it means (one tooltip-sized sentence), why it earns its spot, how it is
* computed, the named caps, and what it deliberately does not cover. The
* "refused" tier documents metrics Atlas will NOT show, and why. This file
- * is the single source of truth; panels and chips render from it. */
+ * is the single source of truth; panels and chips render from it. Chinese
+ * content lives co-located per entry (zh) so translations cannot drift. */
+import type { UiLanguage } from "../lib/i18n";
export type WikiTier = "first-class" | "caveated" | "refused";
@@ -21,6 +23,19 @@ export interface WikiEntry {
appearsIn: string[];
pairedWith?: string;
seeAlso?: string[];
+ /* Simplified-Chinese content; absent fields fall back to English. The
+ * term itself is never translated — the zh panel keeps teaching the
+ * English-canonical token and glosses it in the header. */
+ zh?: {
+ /* Short gloss shown beside the term in the zh panel header. */
+ gloss?: string;
+ /* ≤45 characters — zh is denser, same tooltip budget. */
+ sentence?: string;
+ why?: string;
+ caps?: string[];
+ notCovered?: string;
+ appearsIn?: string[];
+ };
}
export const WIKI_ENTRIES: WikiEntry[] = [
@@ -37,6 +52,16 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Raw commit counts, not size-adjusted; relative churn (per size) is the variant with peer-reviewed defect-prediction backing and is planned as the default axis.",
appearsIn: ["Dashboard", "Symbol file history", "Handout"],
pairedWith: "complexity",
+ zh: {
+ gloss: "变更频率",
+ sentence:
+ "这个文件过去一年改动的频率——预测工作将集中在哪里的最强单一信号。",
+ why: "去年改动过的地方就是接下来还会改的地方——而每次改动都是一次弄坏东西的机会。过程历史对缺陷的预测力,胜过任何针对代码本身的度量。",
+ caps: ["vendored 与生成的路径已被排除"],
+ notCovered:
+ "只是原始提交次数,未按规模调整;相对变更频率(按规模)才是有同行评审缺陷预测证据的变体,计划作为默认轴。",
+ appearsIn: ["仪表盘", "符号页文件历史", "Handout 讲义"],
+ },
},
{
id: "M-COCHANGE",
@@ -50,6 +75,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Pairs below the minimum co-commit support are not shown; the observation window is stated on the panel.",
appearsIn: ["Symbol"],
pairedWith: "coupling",
+ zh: {
+ gloss: "共同变更",
+ sentence:
+ "总和它出现在同一批提交里的文件——真实发生过的耦合,而非 import 暗示的。",
+ why: "如果两个文件总是一起改,它们就是目录树忘了承认的同一个模块。只改其一、落下搭档,是改一半改不完的经典来源。",
+ notCovered: "低于最小共同提交支持度的文件对不显示;观测窗口在面板上注明。",
+ appearsIn: ["符号页"],
+ },
},
{
id: "M-FANIN",
@@ -63,6 +96,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Edges carry resolution confidence; unresolved dynamic calls are not counted.",
appearsIn: ["Symbol", "Galaxy"],
seeAlso: ["confidence", "blast-radius"],
+ zh: {
+ gloss: "扇入/扇出",
+ sentence:
+ "多少符号调用它(扇入),它又调用多少(扇出)——影响范围的原材料。",
+ why: "扇入高,意味着它一坏很多地方都会察觉;扇出高,意味着很多地方一变它就会坏。两端都值得测试与仔细评审。",
+ notCovered: "边带有解析置信度;未解析的动态调用不计入。",
+ appearsIn: ["符号页", "星系"],
+ },
},
{
id: "M-HOTSPOT",
@@ -85,6 +126,18 @@ export const WIKI_ENTRIES: WikiEntry[] = [
appearsIn: ["Dashboard hero", "Changes risk", "Handout"],
pairedWith: "tested",
seeAlso: ["churn", "complexity"],
+ zh: {
+ gloss: "热点",
+ sentence: "改动频繁又难以读懂的文件——修复在这里扎堆,改动在这里最贵。",
+ why: "一小撮热点通常承担着缺陷修复工作的一大部分。相对变更频率能预测缺陷密度,原始行数不能。把精力花在这里,胜过平均摊开。",
+ caps: [
+ "上限:不足 100 行的文件被排除——太小无法排名",
+ "上限:测试文件被排除",
+ ],
+ notCovered:
+ "缺陷密度没有被直接测量——尚无 issue 跟踪器关联。生成或 vendored 的文件会推高变更频率。稳定但纠缠、近期没有提交的文件不会出现在这里;那类文件请单看复杂度。",
+ appearsIn: ["仪表盘英雄区", "变更页风险", "Handout 讲义"],
+ },
},
{
id: "M-CPLX",
@@ -99,6 +152,15 @@ export const WIKI_ENTRIES: WikiEntry[] = [
appearsIn: ["Dashboard", "Symbol"],
pairedWith: "churn",
seeAlso: ["cognitive-complexity"],
+ zh: {
+ gloss: "圈复杂度",
+ sentence:
+ "函数内独立路径的数量——衡量“难测试”尚可,衡量“难读懂”偏弱。",
+ why: "每条独立路径都是测试必须覆盖、读者必须在脑中推演的一种情况。本仓库里高百分位的函数,正是评审变慢、测试成倍增多的地方。",
+ notCovered:
+ "圈复杂度与规模高度相关;显示的百分位只相对本仓库,从来不是绝对的好坏阈值。",
+ appearsIn: ["仪表盘", "符号页"],
+ },
},
{
id: "M-COG",
@@ -112,6 +174,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Better matched to perceived readability than cyclomatic, but still size-confounded.",
appearsIn: ["Dashboard", "Symbol"],
seeAlso: ["complexity"],
+ zh: {
+ gloss: "认知复杂度",
+ sentence:
+ "读者跟随这个函数时,必须在脑中同时保持多少嵌套与控制流中断。",
+ why: "深层嵌套迫使读者把每一层外围条件都留在工作记忆里。这个度量为贴合“代码读起来有多费劲”而设计,比数路径更接近这种感受。",
+ notCovered: "比圈复杂度更贴近主观可读性,但仍受规模干扰。",
+ appearsIn: ["仪表盘", "符号页"],
+ },
},
{
id: "M-COH",
@@ -125,6 +195,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Structural cohesion measures failed empirical validation as quality predictors; a history-based co-change cohesion is the planned replacement. Always read beside coupling.",
appearsIn: ["Overview regions", "Modules"],
pairedWith: "coupling",
+ zh: {
+ gloss: "内聚",
+ sentence: "这个区域的文件在多大程度上真正协作,按内部连接计算。",
+ why: "文件之间几乎不来往的区域只是一个文件夹,不是一个模块——改动会向外扩散而不是留在本地。要和耦合放在一起读:把模块打散,改善其中一个的代价是恶化另一个。",
+ notCovered:
+ "结构性内聚度量作为质量预测指标未通过实证检验;基于历史共同变更的内聚是计划中的替代。永远与耦合并排读。",
+ appearsIn: ["总览区域", "模块"],
+ },
},
{
id: "M-COUP",
@@ -137,6 +215,13 @@ export const WIKI_ENTRIES: WikiEntry[] = [
notCovered: "Only statically resolved calls are counted; confidence applies.",
appearsIn: ["Overview", "Modules"],
pairedWith: "cohesion",
+ zh: {
+ gloss: "耦合",
+ sentence: "两个区域相互依赖的强度,按跨区域调用数计算。",
+ why: "两个区域互相调用越多,就越难把它们分开修改、测试与理解。名义上相互独立的模块之间的重耦合,是这张地图上最可付诸行动的警告。",
+ notCovered: "只统计静态解析成功的调用;置信度同样适用。",
+ appearsIn: ["总览", "模块"],
+ },
},
{
id: "M-BRIDGE",
@@ -155,6 +240,18 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Incoming cross-region popularity is a different signal (see fan-in).",
appearsIn: ["Overview"],
seeAlso: ["fan", "coupling"],
+ zh: {
+ gloss: "跨界符号",
+ sentence: "调用多个外部区域的符号——架构的关节,重构最先疼的地方。",
+ why: "这些符号把架构缝在一起——任何边界重构都会最先落在它们身上。接口一变,正是从这里扩散进外部区域。",
+ caps: [
+ "上限:只统计出向调用",
+ "上限:至少要跨 2 个外部区域",
+ "上限:测试文件被排除",
+ ],
+ notCovered: "入向的跨区域受欢迎度是另一个信号(见 fan-in)。",
+ appearsIn: ["总览"],
+ },
},
{
id: "M-CONF",
@@ -172,6 +269,18 @@ export const WIKI_ENTRIES: WikiEntry[] = [
notCovered:
"Reflection, code generation, and runtime dispatch are not modelled. Coverage is best-effort.",
appearsIn: ["Flows", "Trace", "Symbol connections"],
+ zh: {
+ gloss: "置信度",
+ sentence: "按解析器找到这条调用边的方式,估计它有多可能真实存在。",
+ why: "低置信度的跳步能把一条追踪变成貌似可信却不真实的故事。词和数字永远一起出现:certain ≥95、likely 75–94、uncertain 50–74、speculative <50。",
+ caps: [
+ "上限:跨语言边界 → 至多 likely",
+ "降级:目标重载集大于 1",
+ "speculative:动态分发未解析",
+ ],
+ notCovered: "反射、代码生成与运行时分发未被建模。覆盖为尽力而为。",
+ appearsIn: ["流程", "追踪", "符号页连接"],
+ },
},
{
id: "M-OBSERVED",
@@ -191,6 +300,18 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Absence of observation never means dead or unused — a run covers only what it exercised. Counts survive reindexing (name-keyed), but renamed symbols start fresh.",
appearsIn: ["Flows", "Trace"],
seeAlso: ["confidence", "dead-candidate"],
+ zh: {
+ gloss: "已观测",
+ sentence:
+ "在录制的运行中真实触发过的调用——已观测,而不只是静态分析认为可能。",
+ why: "静态边说的是可能发生什么;观测说的是确实发生过什么。speculative 边上的已观测标记,是解析器判断正确的运行时证据。",
+ caps: [
+ "上限:每个项目 20 万条已观测调用对——整次运行一起老化,最旧的先淘汰",
+ ],
+ notCovered:
+ "缺少观测绝不代表死代码或未使用——一次运行只覆盖它实际执行到的部分。计数按限定名保存、重建索引后仍在,但改名的符号从零开始。",
+ appearsIn: ["流程", "追踪"],
+ },
},
{
id: "M-DEAD",
@@ -204,6 +325,15 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Dynamic dispatch, reflection, exported API consumed outside this repository, and config-referenced entry points all look dead here and are not.",
appearsIn: ["Dashboard"],
seeAlso: ["fan", "confidence"],
+ zh: {
+ gloss: "疑似死代码",
+ sentence:
+ "没有任何已记录调用者的符号——可考虑删除,但必须先核对注意事项。",
+ why: "删除死代码的阻碍是怕误伤,不是找不到。这份列表是证据,不是判决——删除前先做全仓库搜索并跑测试确认。",
+ notCovered:
+ "动态分发、反射、被本仓库之外消费的导出 API、以及被配置引用的入口点,在这里都长得像死代码,但都不是。",
+ appearsIn: ["仪表盘"],
+ },
},
{
id: "M-TESTED",
@@ -218,6 +348,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
appearsIn: ["Dashboard", "Symbol"],
pairedWith: "hotspot",
seeAlso: ["coverage-gates"],
+ zh: {
+ gloss: "测试触达",
+ sentence: "有 TESTS 边到达这个符号——某个测试直接或经调用链运行到它。",
+ why: "没有测试到达的符号只会在生产环境里失败。触达是安全的下限;没有触达的热点是仓库里风险最高的代码。",
+ notCovered:
+ "触达不等于断言:测试可以执行这段代码却不检查它的结果。Atlas 有意展示触达,而不是覆盖率百分比。",
+ appearsIn: ["仪表盘", "符号页"],
+ },
},
{
id: "M-DOC",
@@ -230,6 +368,13 @@ export const WIKI_ENTRIES: WikiEntry[] = [
notCovered:
"Comment presence only; accuracy and usefulness are not assessed.",
appearsIn: ["Dashboard"],
+ zh: {
+ gloss: "有文档",
+ sentence: "带文档注释的导出符号——可解释性的下限,不衡量文档质量。",
+ why: "没有文档的导出迫使每个调用者去读实现。一条文档注释是廉价的下限,在每个调用点——以及每条智能体提示里——都有回报。",
+ notCovered: "只看注释是否存在;准确性与有用性不做评估。",
+ appearsIn: ["仪表盘"],
+ },
},
{
id: "M-DIVERG",
@@ -242,6 +387,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
notCovered:
"Duplication alone is a weak signal; identical, stable copies are mostly harmless. Divergence under change is the hazard this view ranks.",
appearsIn: ["Symbol near-clones"],
+ zh: {
+ gloss: "副本漂移",
+ sentence: "已经开始各自漂移的代码副本——风险在漂移,不在重复本身。",
+ why: "副本一旦漂移,在一处修掉的 bug 会在另一处活下去。漂移中的近似克隆,就是已经开始互相矛盾的那些副本。",
+ notCovered:
+ "单纯的重复是弱信号;完全相同且稳定的副本大多无害。这个视图排的是变更之下的漂移这种危险。",
+ appearsIn: ["符号页近似克隆"],
+ },
},
{
id: "M-HELP",
@@ -254,6 +407,15 @@ export const WIKI_ENTRIES: WikiEntry[] = [
notCovered:
"Atlas never ranks people against each other and never shows per-person productivity. Names appear only with their evidence: commits, recency, breadth.",
appearsIn: ["Symbol file history"],
+ zh: {
+ gloss: "可求助的人",
+ sentence:
+ "近期在这段代码上有实质历史的人——该问谁的证据,绝不是绩效度量。",
+ why: "二十年的开发者研究里,被寻求最多的信息是同事知道什么。当图谱给不出答案时,找对人是最快的路——这里展示是谁,并附上证据。",
+ notCovered:
+ "Atlas 从不把人相互排名,也从不展示个人生产力。名字只与证据一同出现:提交、新近度、广度。",
+ appearsIn: ["符号页文件历史"],
+ },
},
{
id: "M-REGION",
@@ -267,6 +429,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Inferred from call structure, not from directory names; a region panel must answer why is this here — members, internal density, top external ties.",
appearsIn: ["Galaxy", "Overview", "Modules"],
seeAlso: ["cohesion", "coupling"],
+ zh: {
+ gloss: "区域",
+ sentence: "相互调用多于对外调用的一簇文件——Atlas 推断出的模块。",
+ why: "从真实调用结构推断出的模块,展示的是架构的实际样子,而不是目录树宣称的样子。两者不一致的地方通常值得一看。",
+ notCovered:
+ "从调用结构推断,与目录名无关;区域面板必须回答“为什么在这里”——成员、内部密度、最强的外部联系。",
+ appearsIn: ["星系", "总览", "模块"],
+ },
},
{
id: "M-HUB",
@@ -282,6 +452,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
notCovered: "Connectivity is static; a rarely-executed hub still ranks.",
appearsIn: ["Galaxy halos", "Overview"],
seeAlso: ["fan"],
+ zh: {
+ gloss: "枢纽",
+ sentence: "图中连接最多的符号——其余代码直接或间接最依赖的那些。",
+ why: "枢纽一变,处处有感;一个枢纽出事,就是多处一起出事。枢纽配得上仓库里最强的测试与最仔细的评审。",
+ caps: ["上限:按连通度取前 12 个加光环;截断是显示上的选择,不是断崖"],
+ notCovered: "连通度是静态的;很少被执行的枢纽同样上榜。",
+ appearsIn: ["星系光环", "总览"],
+ },
},
{
id: "M-BLAST",
@@ -295,6 +473,14 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Static CALLS edges only — dynamic dispatch, reflection and code generation are invisible here, so every count is a floor. The walk is capped in depth and volume; caps are always stated.",
appearsIn: ["Changes", "Symbol — If you change this"],
seeAlso: ["fan", "confidence"],
+ zh: {
+ gloss: "影响范围",
+ sentence: "所有能到达你所改代码的东西——哪些地方可能察觉,按区域分组。",
+ why: "多数回归之所以上线,是因为改动只在发生它的地方被测试,而不是在感受到它的地方。这份影响列表就是推送前要重测的内容。",
+ notCovered:
+ "只有静态 CALLS 边——动态分发、反射与代码生成在这里不可见,因此每个数字都是下限。遍历有深度与数量上限;上限永远注明。",
+ appearsIn: ["变更", "符号页——如果你改动这里"],
+ },
},
{
id: "M-SCENT",
@@ -307,6 +493,13 @@ export const WIKI_ENTRIES: WikiEntry[] = [
notCovered:
"Name and text matches only; File and Folder nodes are excluded from counts.",
appearsIn: ["Galaxy minimap", "Search"],
+ zh: {
+ gloss: "气味",
+ sentence: "搜索词在地图上的聚集位置——跟着气味走,别靠猜。",
+ why: "画在地图上的搜索结果显示一个概念住在哪里、有多集中——一片亮区意味着干净的归属;散落的命中意味着横切关注点。",
+ notCovered: "只匹配名称与文本;File 与 Folder 节点不计入计数。",
+ appearsIn: ["星系小地图", "搜索"],
+ },
},
{
id: "M-NEG-MI",
@@ -317,6 +510,13 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Atlas does not show a Maintainability Index: its weights are folklore, it double-counts size, and it failed empirical validation.",
why: "The MI's constants were fit to a handful of 1990s Hewlett-Packard systems and never revalidated; size dominates every term. What Atlas shows instead: churn, complexity and size separately, each with its own percentile.",
appearsIn: ["Wiki only"],
+ zh: {
+ gloss: "可维护性指数",
+ sentence:
+ "Atlas 不展示可维护性指数:权重是民间传说,重复计算规模,且未通过实证检验。",
+ why: "MI 的常数拟合自 1990 年代惠普的少数几个系统,此后从未重新验证;规模主导每一项。Atlas 转而分别展示变更频率、复杂度与规模,各带自己的百分位。",
+ appearsIn: ["仅在 Wiki"],
+ },
},
{
id: "M-NEG-HAL",
@@ -327,6 +527,13 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"Atlas does not compute Halstead metrics: token-counting science from 1977 that never replicated; size does its job better.",
why: "Operator-and-operand counting promised effort and bug prediction it never delivered under replication; every useful signal it carries, plain size carries better.",
appearsIn: ["Wiki only"],
+ zh: {
+ gloss: "Halstead 度量",
+ sentence:
+ "Atlas 不计算 Halstead:1977 年的记号计数从未复现;规模干得更好。",
+ why: "算符与操作数计数许诺的工作量与缺陷预测,在复现研究中从未兑现;它携带的每一个有用信号,朴素的规模都携带得更好。",
+ appearsIn: ["仅在 Wiki"],
+ },
},
{
id: "M-NEG-COV",
@@ -338,6 +545,13 @@ export const WIKI_ENTRIES: WikiEntry[] = [
why: "The correlation between coverage and post-release defects is weak and disappears above roughly 70–80%. Atlas shows test reach per symbol so you can judge the gap that matters.",
appearsIn: ["Wiki only"],
seeAlso: ["tested"],
+ zh: {
+ gloss: "覆盖率门槛",
+ sentence:
+ "Atlas 展示哪些测试到达符号,从不设覆盖率百分比目标:僵硬的指标催生无断言的测试。",
+ why: "覆盖率与发布后缺陷的相关性很弱,超过大约 70–80% 后就消失了。Atlas 按符号展示测试触达,让你自己判断真正要紧的缺口。",
+ appearsIn: ["仅在 Wiki"],
+ },
},
{
id: "M-NEG-GRADE",
@@ -348,6 +562,13 @@ export const WIKI_ENTRIES: WikiEntry[] = [
"No A–F, no 0–100: a percentile in this repository carries the same information with no invented scale to misread.",
why: "Published score curves still get read as linear; grades measurably undermine interest and performance relative to explanations; single scores with consequences invite gaming. Atlas ships percentiles, distributions and named caps instead.",
appearsIn: ["Wiki only"],
+ zh: {
+ gloss: "质量评级",
+ sentence:
+ "不给 A–F 也不给 0–100:仓库内百分位承载同样信息,且没有会被误读的人造刻度。",
+ why: "公开的评分曲线仍会被当成线性来读;相比解释,评级会切实削弱兴趣与表现;带后果的单一分数招致刷分。Atlas 提供的是百分位、分布与点名的上限。",
+ appearsIn: ["仅在 Wiki"],
+ },
},
];
@@ -361,3 +582,25 @@ export function wikiEntry(slug: string): WikiEntry | undefined {
export function wikiEntryById(id: string): WikiEntry | undefined {
return byId.get(id);
}
+
+/* One entry as one locale sees it: zh fields when the locale is zh and the
+ * field exists, English fallback field-by-field. The term itself stays
+ * English-canonical — chips, headings and breadcrumbs keep teaching the
+ * token readers meet in code, docs and issues; the gloss rides beside it. */
+export interface WikiEntryView extends Omit<WikiEntry, "zh"> {
+ gloss?: string;
+}
+
+export function localizeEntry(entry: WikiEntry, lang: UiLanguage): WikiEntryView {
+ const { zh, ...en } = entry;
+ if (lang !== "zh" || !zh) return en;
+ return {
+ ...en,
+ gloss: zh.gloss,
+ sentence: zh.sentence ?? en.sentence,
+ why: zh.why ?? en.why,
+ caps: zh.caps ?? en.caps,
+ notCovered: zh.notCovered ?? en.notCovered,
+ appearsIn: zh.appearsIn ?? en.appearsIn,
+ };
+}
diff --git a/graph-ui/tsconfig.tsbuildinfo b/graph-ui/tsconfig.tsbuildinfo
index 2dc75298f..2815dcb9e 100644
--- a/graph-ui/tsconfig.tsbuildinfo
+++ b/graph-ui/tsconfig.tsbuildinfo
@@ -1 +1 @@
-{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/rpc.ts","./src/components/changestab.tsx","./src/components/commandk.tsx","./src/components/controltab.tsx","./src/components/dashboardtab.tsx","./src/components/displaysettingsmenu.tsx","./src/components/edgelines.tsx","./src/components/errorboundary.tsx","./src/components/filterpanel.tsx","./src/components/flowstab.observed.test.tsx","./src/components/flowstab.tsx","./src/components/graphloader.tsx","./src/components/graphscene.test.ts","./src/components/graphscene.tsx","./src/components/graphtab.deadcode.test.tsx","./src/components/graphtab.filters.test.tsx","./src/components/graphtab.regions.test.tsx","./src/components/graphtab.test.ts","./src/components/graphtab.tsx","./src/components/halolayer.tsx","./src/components/metricchip.tsx","./src/components/minimap.tsx","./src/components/missedcallout.tsx","./src/components/modulestab.tsx","./src/components/nodecloud.tsx","./src/components/nodedetailpanel.showmore.test.tsx","./src/components/nodedetailpanel.test.tsx","./src/components/nodedetailpanel.tsx","./src/components/nodelabels.tsx","./src/components/nodetooltip.tsx","./src/components/overviewtab.tsx","./src/components/projectcard.tsx","./src/components/projectswitcher.tsx","./src/components/promptbasket.tsx","./src/components/regionpanel.tsx","./src/components/regiontooltip.tsx","./src/components/resizehandle.tsx","./src/components/sidebar.tsx","./src/components/statstab.test.tsx","./src/components/statstab.tsx","./src/components/symboltab.tsx","./src/components/tabbar.tsx","./src/components/triggertree.tsx","./src/components/wikihovercard.test.tsx","./src/components/wikihovercard.tsx","./src/components/wikipanel.test.tsx","./src/components/wikipanel.tsx","./src/components/wikitier.ts","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/input.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/separator.tsx","./src/hooks/usegraphdata.test.ts","./src/hooks/usegraphdata.ts","./src/hooks/useprojects.ts","./src/lib/atlas.test.ts","./src/lib/atlas.ts","./src/lib/colors.ts","./src/lib/complexity.test.ts","./src/lib/complexity.ts","./src/lib/composer.ts","./src/lib/density.test.ts","./src/lib/density.ts","./src/lib/findings.test.ts","./src/lib/findings.ts","./src/lib/firstread.ts","./src/lib/flowgroup.test.ts","./src/lib/flowgroup.ts","./src/lib/i18n.test.ts","./src/lib/i18n.ts","./src/lib/impact.test.ts","./src/lib/impact.ts","./src/lib/observed.test.ts","./src/lib/observed.ts","./src/lib/questions.test.ts","./src/lib/questions.ts","./src/lib/rationale.test.ts","./src/lib/rationale.ts","./src/lib/regions.test.ts","./src/lib/regions.ts","./src/lib/treemap.ts","./src/lib/types.ts","./src/lib/utils.ts","./src/lib/why.test.ts","./src/lib/why.ts","./src/lib/whyfetch.ts","./src/test/setup.ts","./src/wiki/entries.test.ts","./src/wiki/entries.ts"],"version":"5.9.3"}
\ No newline at end of file
+{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/rpc.ts","./src/components/changestab.tsx","./src/components/commandk.tsx","./src/components/controltab.tsx","./src/components/dashboardtab.tsx","./src/components/displaysettingsmenu.tsx","./src/components/edgelines.tsx","./src/components/errorboundary.tsx","./src/components/filterpanel.tsx","./src/components/flowstab.observed.test.tsx","./src/components/flowstab.tsx","./src/components/graphloader.tsx","./src/components/graphscene.test.ts","./src/components/graphscene.tsx","./src/components/graphtab.deadcode.test.tsx","./src/components/graphtab.filters.test.tsx","./src/components/graphtab.regions.test.tsx","./src/components/graphtab.test.ts","./src/components/graphtab.tsx","./src/components/halolayer.tsx","./src/components/metricchip.tsx","./src/components/minimap.tsx","./src/components/missedcallout.tsx","./src/components/modulestab.tsx","./src/components/nodecloud.tsx","./src/components/nodedetailpanel.showmore.test.tsx","./src/components/nodedetailpanel.test.tsx","./src/components/nodedetailpanel.tsx","./src/components/nodelabels.tsx","./src/components/nodetooltip.tsx","./src/components/overviewtab.tsx","./src/components/projectcard.tsx","./src/components/projectswitcher.tsx","./src/components/promptbasket.tsx","./src/components/regionpanel.tsx","./src/components/regiontooltip.tsx","./src/components/resizehandle.tsx","./src/components/sidebar.tsx","./src/components/statstab.test.tsx","./src/components/statstab.tsx","./src/components/symboltab.tsx","./src/components/tabbar.tsx","./src/components/triggertree.tsx","./src/components/wikihovercard.test.tsx","./src/components/wikihovercard.tsx","./src/components/wikipanel.test.tsx","./src/components/wikipanel.tsx","./src/components/wikipanel.zh.test.tsx","./src/components/wikitier.ts","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/input.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/separator.tsx","./src/hooks/usegraphdata.test.ts","./src/hooks/usegraphdata.ts","./src/hooks/useprojects.ts","./src/lib/atlas.test.ts","./src/lib/atlas.ts","./src/lib/colors.ts","./src/lib/complexity.test.ts","./src/lib/complexity.ts","./src/lib/composer.ts","./src/lib/density.test.ts","./src/lib/density.ts","./src/lib/findings.test.ts","./src/lib/findings.ts","./src/lib/firstread.ts","./src/lib/flowgroup.test.ts","./src/lib/flowgroup.ts","./src/lib/i18n.test.ts","./src/lib/i18n.ts","./src/lib/impact.test.ts","./src/lib/impact.ts","./src/lib/observed.test.ts","./src/lib/observed.ts","./src/lib/questions.test.ts","./src/lib/questions.ts","./src/lib/rationale.test.ts","./src/lib/rationale.ts","./src/lib/regions.test.ts","./src/lib/regions.ts","./src/lib/treemap.ts","./src/lib/types.ts","./src/lib/utils.ts","./src/lib/why.test.ts","./src/lib/why.ts","./src/lib/whyfetch.ts","./src/test/setup.ts","./src/wiki/entries.test.ts","./src/wiki/entries.ts"],"version":"5.9.3"}
\ No newline at end of file