Skip to content

feat(localization): 缺中文的 key 由机器人机翻草稿补齐,不再卡 PR - #611

Merged
gansx merged 1 commit into
mainfrom
gansx/zh-draft-autofill
Oct 28, 2026
Merged

gansx merged 1 commit into
mainfrom
gansx/zh-draft-autofill

Conversation

@gansx

@gansx gansx commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

背景

#608 落地后仍有不一致:新文案只写英文时,53 个语言由机器人机翻补齐,唯独 zh-CN 被 check:i18n 的 en/zh 奇偶校验硬卡住。在 agent 生成文案的工作流里,缺中文是疏忽而非决策,应享受同样的机翻兜底。设计修订见 docs/design/translation-catalog-automation.md 第 7 节。

改动

  1. draft-missing-chinese.mjs(新增):找出"英文源有、中文源无"的 key(TS 字典 + additional JSON 都覆盖),走同一 Google 端点机翻 zh 草稿(同样的占位符/受保护 token/非空校验),写回真实源文件(zh-CN.ts 根部 / additional-zh-CN.json)。草稿进入源后,import、parity、PR 评审都按正常内容对待。
  2. 两个工作流:import 前先跑草稿脚本;提交范围扩到 zh-CN.ts;PR 工作流推送后尝试 gh pr comment 列出机翻草稿 key 清单供人工润色(评论失败只警告不影响主流程)。
  3. check-i18n.mjs:en/zh 缺口从硬失败降为信息输出;重复 key 仍硬失败。
  4. 共享模块:google-translate.mjs(端点调用)与 web-locale-sources.mjs(TS 字典解析)抽取复用,既有两脚本行为不变。

验证

  • draft-missing-chinese.test.mjs:无网络桩覆盖无缺口 no-op、两类容器补齐、二次运行幂等、占位符丢失/空译文 fail-closed
  • localization 全套 19/19;check-catalogs 通过;import 幂等无 diff;check-i18n 通过
  • 契约测试 13/13(新增草稿顺序、提交范围、评论降级断言)
  • 当前 main 实跑草稿脚本正确输出 {"drafted":[]}(无缺口)
  • 合并后将用一个只写英文的测试 PR 实测端到端

…hinese

The en/zh parity check in check:i18n assumed both source dictionaries are
hand-written; in the agent-driven workflow a missing zh-CN entry is an
oversight, not a decision, and should get the same machine-translation
backstop as the other 53 locales.

- draft-missing-chinese.mjs finds keys present in the English sources but
  absent from every Chinese source, translates them through the same Google
  endpoint with the same placeholder/protected-token validation, and writes
  drafts into the real sources (zh-CN.ts root dictionary or
  additional-zh-CN.json) so import, parity checks, and PR review all see them.
- Both translation workflows run the draft step before importing; the PR
  workflow reports the drafted keys in a best-effort PR comment.
- check:i18n downgrades en/zh gap reports to informational output; duplicate
  keys remain hard failures.
- Shared google-translate.mjs / web-locale-sources.mjs modules keep the two
  existing scripts' behavior identical (verified: import stays idempotent,
  catalogs unchanged, 19/19 localization tests pass).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T07:15:06.387445Z 0190701 PR opened
🔒 Security Review ✅ Completed 2026-10-28T07:20:14.695948Z 0190701 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gansx
gansx merged commit 80a6b8e into main Oct 28, 2026
15 checks passed
@gansx
gansx deleted the gansx/zh-draft-autofill branch October 28, 2026 07:46
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.

1 participant