Skip to content

docs(zh): 补全剩余文档的简体中文翻译,并新增 AI 翻译提示#1622

Open
chenglu wants to merge 36 commits into
cfug:mainfrom
chenglu:translate/remaining-docs-zh
Open

docs(zh): 补全剩余文档的简体中文翻译,并新增 AI 翻译提示#1622
chenglu wants to merge 36 commits into
cfug:mainfrom
chenglu:translate/remaining-docs-zh

Conversation

@chenglu

@chenglu chenglu commented Jun 4, 2026

Copy link
Copy Markdown
Member

概述

补全 docs.flutter.cn 上剩余未翻译文档的简体中文翻译,并新增「本页内容由 AI 翻译」提示,邀请读者参与校阅。

按既有的中英对照惯例处理:保留英文原文,将中文译文直接追加在对应英文下方,维持原有结构与缩进,便于上游更新时人工 diff、仅更新对应中文。

改动内容

本 PR 拆成两个 commit,方便分别 review:

1. docs(zh):翻译内容(约 280 个文件)

  • 覆盖 ui/platform-integration/cookbook/ai/learn/testing/app-architecture/tools/install/ 等目录,以及共享的 _includes/ 片段
  • 遵循术语表,与现有人工译文风格保持一致(统一使用「你」、中英文间保留半角空格、全角标点等)
  • 借助 AI 完成的页面在 frontmatter 中标记 ai-translated: true
  • 不含 release/ 发版说明与 DevTools release-notes(按约定排除)

2. feat(docs):AI 翻译提示功能

  • 新增 AiTranslationNotice 组件(lib/src/components/common
  • DocLayout 中检测 frontmatter 的 ai-translated: true 时渲染提示横幅,并链接到该页源文件,方便校阅
  • _alert.scss 新增 .alert-ai-translation 样式
  • 修复 translator 的 gulp 任务,对缺失的旧版路径容错(allowEmpty),使纯中文导出流程能在 Jaspr 产物上运行

测试

  • dart run dash_site build 构建成功(716 页,无错误)
  • 本地跑通 tool/translator/build.sh 的 inject + export --mono 流程,验证:英文原文正确折叠、中文完整保留、AI 提示横幅在译文页正常显示
  • 校验列表格式:中文译文作为缩进续行置于同一列表项内(而非拆成两个 <li>),确保翻译工具能正确折叠

说明

ai-translated 为本 PR 新引入的 frontmatter 字段,由上述 layout 逻辑识别,对未标记的页面无影响。

Made with Cursor

chenglu and others added 2 commits June 4, 2026 16:18
Introduce an AiTranslationNotice banner shown on pages whose Chinese
translation was produced with AI assistance, inviting readers to review
and contribute corrections on GitHub.

- Add AiTranslationNotice component (lib/src/components/common)
- Render it in DocLayout when frontmatter has `ai-translated: true`,
  linking to the page source for review
- Style `.alert-ai-translation` variant in _alert.scss
- Fix translator gulp tasks to tolerate missing legacy paths
  (allowEmpty) so the mono export pipeline runs on the Jaspr output

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Simplified Chinese translations for the remaining untranslated
documentation, following the established bilingual convention: the
English source is preserved and the Chinese translation is appended
directly beneath it, keeping the original structure and indentation so
upstream updates remain easy to diff and re-translate.

Covers content under ui/, platform-integration/, cookbook/, ai/,
learn/, testing/, app-architecture/, tools/, install/ and others, plus
shared _includes snippets. Pages translated with AI assistance are
flagged with `ai-translated: true` in frontmatter.

Excludes the release/ notes and DevTools release-notes by request.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings June 4, 2026 21:03
@chenglu chenglu requested a review from a team as a code owner June 4, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

chenglu and others added 3 commits June 4, 2026 17:26
- offline-first.md: restore the API client paragraph block that was
  garbled during translation (duplicated lines and a truncated
  `<?code-excerpt` directive), fixing the "Invalid code excerpt syntax"
  build error
- create-new-app.md: add the missing `[ij-set-org]` link reference
  definition and its Chinese translation, fixing the broken Markdown
  link reference reported by check-link-references

Both `check-link-references` and `refresh-excerpts --fail-on-update`
now pass locally.

Co-authored-by: Cursor <cursoragent@cursor.com>
The `[ai-toolkit]` reference definition was changed from the correct
`/ai-toolkit` to `/ai/toolkit` during translation, producing a 404 in
the internal link checker. Restore the upstream path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Translating the footnotes produced duplicate `[^n]:` definitions and a
duplicated `[^4]` reference across the English and Chinese table rows.
After the mono (Chinese-only) export folds away the English row, the
`fnref-4` backref anchor disappeared, tripping the internal link
checker with a "missing anchor" warning.

- Collapse each footnote into a single definition with the English
  text preserved and the Chinese translation as an indented continuation
- Follow the established bilingual convention (see architectural-overview)
  of commenting out the footnote marker on the English row
  (`<!-- [^4] -->`) so the live anchor lives on the retained Chinese row

Verified: after build + translator mono export, all footnote backrefs
resolve to existing anchors.

Co-authored-by: Cursor <cursoragent@cursor.com>
@chenglu

chenglu commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

预览: https://docs-ai-translation-preview.flutter.cn/

谢谢 cursor 老师,谢谢中转站老师。

chenglu and others added 9 commits June 4, 2026 20:58
- Convert Chinese list items from separate `* **中文**` entries to
  properly indented continuation paragraphs within the English list item
  (65 instances across 20+ files)
- Fix duplicate headings where API names like `HtmlElementView` appeared
  identically in both English and Chinese rows (add descriptive suffixes)
- Replace mechanical "允许你" (allows you) with natural "让你" phrasing
  (44 instances)

All changes verified: build passes, check-link-references and
refresh-excerpts both clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
…iners

Translation agents incorrectly produced separate English and Chinese
:::note/tip/warning blocks, causing the page to render two identical
admonition boxes. Merged 82 consecutive block pairs into unified
bilingual containers (English content + Chinese translation in a single
::: block), matching the established convention.

Also fixes 6 remaining list formatting issues in property-editor.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
Distilled from real production issues encountered during batch
translation of 295 files. Covers formatting rules, common pitfalls
(duplicate tip blocks, list items, footnotes, headings), quality
standards, self-check procedures, and terminology glossary.

Co-authored-by: Cursor <cursoragent@cursor.com>
修复 markdown 列表中中文翻译的格式问题:
- 有序列表:移除中文翻译行前的 `1. ` 前缀,改为缩进续行
- 无序列表:移除中文翻译行前的 `- ` / `* ` 前缀,改为缩进续行

修复前(错误,会渲染为嵌套子列表):
  1. English text
     1. 中文翻译

修复后(正确,中文作为同一列表项的续行):
  1. English text
     中文翻译

共修复 84 个文件,588 处问题。

Co-authored-by: Cursor <cursoragent@cursor.com>
- 移除 2./3./4. 等编号前缀(之前只处理了 1.)
- 修复中文翻译行缩进不足导致 markdown 结构被破坏的问题
  (如 link reference 因缩进错误未被识别)

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants