Skip to content

Feat/dashboard i18n chinese - 代码报告看板兼容中文#130

Closed
aojiev wants to merge 18 commits into
Lum1104:mainfrom
aojiev:feat/dashboard-i18n-chinese
Closed

Feat/dashboard i18n chinese - 代码报告看板兼容中文#130
aojiev wants to merge 18 commits into
Lum1104:mainfrom
aojiev:feat/dashboard-i18n-chinese

Conversation

@aojiev
Copy link
Copy Markdown

@aojiev aojiev commented May 8, 2026

No description provided.

aojiev added 14 commits May 8, 2026 16:36
i18n keys added:
- pathFinder: title, description, fromNode, toNode, selectNode, findPath, searching, noPath, pathFound, nodes
- persona: overviewDesc, learnDesc, deepDiveDesc
- diff: diff, on, off, hideOverlay, showOverlay, noData, changed, affected
- codeViewer: noFileSelected, linesRange, fullFile, openLarger, close, closeExpanded, loading, sourceUnavailable, lineCount
- fileExplorer: noFilePaths
- token: unexpectedResponse, serverUnreachable
- warning: all fatal/autoCorrection/droppedItem pluralization keys, copyTextFatal1/2, copyTextNonFatal1/2/3, copied, copyIssues, copyFatal, copyNonFatal, clipboardFailed, expand, collapse
- layer: layersCount
@aojiev aojiev marked this pull request as draft May 8, 2026 12:45
@aojiev aojiev marked this pull request as ready for review May 8, 2026 12:45
@aojiev aojiev changed the title Feat/dashboard i18n chinese Feat/dashboard i18n chinese - 代码报告看板兼容中文 May 8, 2026
@aojiev
Copy link
Copy Markdown
Author

aojiev commented May 8, 2026

Summary / 简介

This PR introduces internationalization (i18n) support to the Dashboard and adds a complete Chinese (Simplified) translation. It replaces all hardcoded strings across the UI components with i18n keys and provides a language switcher for users to toggle between English and Chinese seamlessly.
本 PR 为 Dashboard 引入了国际化(i18n)支持,并添加了完整的简体中文翻译。它将所有 UI 组件中的硬编码字符串替换为 i18n 键值,并提供了一个语言切换器,方便用户在中英文之间无缝切换。

Changes / 主要更改

  • i18n Setup / 国际化配置:
    • Added react-i18next and i18next-browser-languagedetector dependencies.
    • Configured i18n instance in src/i18n/index.ts with auto-detection and fallback to English.
    • 新增了 react-i18next 等依赖,并在 src/i18n/index.ts 中完成了 i18n 实例的配置(支持自动检测语言,默认回退为英文)。
  • Language Picker / 语言切换器:
    • Added a new LanguagePicker component to the app header for easy language switching.
    • 在应用顶部导航栏新增了 LanguagePicker 组件,用于快速切换语言。
  • Component Refactoring / 组件重构:
    • Refactored all dashboard components (App, FilterPanel, LearnPanel, NodeInfo, SearchBar, ExportMenu, CodeViewer, etc.) to use the useTranslation hook.
    • 重构了所有 Dashboard 组件(包括 App, FilterPanel, LearnPanel, NodeInfo, SearchBar, ExportMenu, CodeViewer 等),使用 useTranslation hook 替换硬编码的文本。
  • Translation Files / 翻译文件:
    • Created comprehensive en.json and zh.json locale files covering all UI text, tooltips, and warnings.
    • 创建了完整的 en.jsonzh.json 语言包,覆盖了所有 UI 文本、提示信息和警告。
  • Skill Update / Skill 更新:
    • Updated understand/SKILL.md to generate content in the same language as the project codebase.
    • 更新了 understand/SKILL.md,使生成的内容与项目代码库的语言保持一致。

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering how to define if a codebase is "Chinese Code"? The README or something.

I'd recommend the skill to ask the user~

@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 10, 2026

Code review

Found 5 issues:

  1. 5 个组件里的标题样式从 font-heading (PR feat: customizable heading font via theme settings #121 引入的主题化变量 --font-heading) 回退成了 font-serif,绕开了用户的 headingFont 偏好,并退回到浏览器默认 serif 字体。diff 里能看到 -font-heading / +font-serif 的对应行,不是分支 stale。(CLAUDE.md: "Dark luxury theme: deep blacks (#0a0a0a), gold/amber accents (#d4a574), DM Serif Display typography")

<div>
<h2 className="text-xl font-serif text-text-primary">
{t("keyboard.keyboardShortcuts")}

同样的回退也出现在 LearnPanel.tsx#L44MobileLayout.tsx#L100PathFinderModal.tsx#L129TokenGate.tsx#L44

  1. pnpm-workspace.yaml 新增的 allowBuilds 段每一项 value 都是字面量字符串 "set this to true or false",不是 boolean —— 像是模板占位符没填。pnpm 的 allowBuilds 要求 true/false,这样写实际不会放行任何构建。另外 PR fix(skill): make /understand work on Windows + pnpm 10 #124 (commit a381c41) 已经在 understand-anything-plugin/package.json 通过 pnpm.onlyBuiltDependencies 解决了同一问题,这个 workspace 级别的配置也是重复的,可以直接去掉。

- "packages/*"
allowBuilds:
esbuild: set this to true or false
tree-sitter-c: set this to true or false
tree-sitter-c-sharp: set this to true or false
tree-sitter-cpp: set this to true or false
tree-sitter-go: set this to true or false
tree-sitter-java: set this to true or false
tree-sitter-javascript: set this to true or false
tree-sitter-php: set this to true or false
tree-sitter-python: set this to true or false
tree-sitter-ruby: set this to true or false
tree-sitter-rust: set this to true or false
tree-sitter-typescript: set this to true or false

  1. locale 文件用了 i18next v3 时代的 _plural 后缀 (fatalError_pluralautoCorrection_pluraldroppedItem_plural),但项目锁的是 i18next ^26.0.10,而 i18n/index.ts 又没有设置 compatibilityJSON: 'v3'。i18next v21+ 改用 CLDR 风格的 _one / _other,所以这些 _plural 键会被静默忽略 —— t("warning.fatalError", { count: 2 }) 永远返回单数文案。WarningBanner 在 count ≥ 2 时中英文都会渲染错误。(runtime bug)

"copy": "Copy",
"fatalError": "{{count}} fatal error",
"fatalError_plural": "{{count}} fatal errors",
"autoCorrection": "{{count}} auto-correction",
"autoCorrection_plural": "{{count}} auto-corrections",
"droppedItem": "{{count}} dropped item",
"droppedItem_plural": "{{count}} dropped items",
"dashboardHit": "Dashboard hit {{parts}}",
"graphLoaded": "Knowledge graph loaded with {{parts}}",

i18n 初始化缺 compatibilityJSON:

.use(initReactI18next)
.init({
resources: {
en: { translation: en },
zh: { translation: zh },
},
fallbackLng: "en",
supportedLngs: SUPPORTED_LANGUAGES,
interpolation: {
escapeValue: false,
},
detection: {
order: ["localStorage", "navigator"],
caches: ["localStorage"],
lookupLocalStorage: "understand-anything-language",
},
});

  1. WarningBanner.tsx 用硬编码的英文 " and " 把已经翻译过的短语拼起来,在中文环境下会渲染成类似 知识图谱已加载,包含 1 个致命错误 and 2 个自动修复 的混合串。多警告场景必现。(bug)

const summary = hasFatal
? t("warning.dashboardHit", { parts: parts.join(", ") })
: t("warning.graphLoaded", { parts: parts.join(" and ") });

  1. App.tsx 里的 / 快捷键用 document.querySelector('input[placeholder*="Search"]') 来 focus 搜索框 —— 这个 selector 写死了英文 "Search"。本 PR 把 placeholder 接到 t('search.placeholder') 后,中文下变成 搜索节点...,selector 匹配不到,快捷键就静默失效了。建议改用稳定的 id / data-testid / forwarded ref。(bug)

description: "Focus search bar",
action: () => {
const searchInput = document.querySelector<HTMLInputElement>(
'input[placeholder*="Search"]'
);
searchInput?.focus();

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 10, 2026

补一句 process 上的建议(无意冒犯):

看 18 个 commits 的粒度,像是 AI 一个文件一个文件改出来的。这种工作流下 AI 看不到跨文件影响,所以才漏掉:

  • / 快捷键 selector 在另一个文件里写死了 "Search"(issue 5)
  • WarningBanner 自己拼的 " and ",跟 i18n 主题撞车(issue 4)
  • merge 时把已经存在的 font-heading 误改回 font-serif(issue 1)

这几个问题如果作者在合 PR 之前 pnpm dev:dashboard 跑起来切到中文,基本一眼就发现了。下次 AI 写完整体 grep 一下 + 浏览器里实际点一下,大概能筛掉 80% 这种。

@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 12, 2026

Hi, thanks for your contribution. I'll close this for the problem has been solved by #142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants