feat(i18n): T6 真实翻译入仓与 Phase 3 收敛归档

- op-artalk 车道:6/6 篇 TMT 翻译入 posts-en(frontmatter 字节级透传),
  幂等复跑 0 API;修复 TMT 1800+ 字符包静默截断(limit 1600 + ratio
  检测 + 二分降级,mock 三场景)
- 标题首字母抛光;T8 staging 21 页 + rollback 绿 + halo 无恙
- spec_verify --all 八项同指纹 exit=0;check 一次收敛;归档

验证: 21 页 build exit 0;/en/ 文章页真实英文内容渲染
      (Under the Veil… 抽检);幂等 dry-run 6 skip 0 API

Spec: 2026-10-25_add-blog-i18n
Co-authored-by: GLM-5.3
This commit is contained in:
wait4xandGLM-5.3 committed 2026-10-25 09:40:59 +08:00
1 parent 4aa79fca06
commit e185a292c8
15 files changed
+1204 -15

No files matched your search

@@ -0,0 +1,95 @@
# Phase 3:双语骨架 + 腾讯 TMT 翻译管线 - 完成总结
## 交付结论
- 结果:完成
- 完成时间:2026-10-25 09:40
## 假设回顾
### 已验证假设
- TMT TextTranslate 单请求上限 2000 字符,长文需分块(按段落聚合)
- TMT 译文对文学内容质量有限,AI 标注 + 可人工润色锁定是补偿机制
### 仍未完全验证的假设
- 无
## 交付范围
### 已交付
- T1 astro i18n 配置 + locale 管道
- T2 UI 字典 + 组件串接
- T3 语言切换组件(Header 中英互跳)
- T4 /en/ 页面骨架 + AI 译文标注组件
- T5 TMT 翻译管线
- T6 存量翻译执行 + 标注落页
- T7 hreflang + 双语 RSS + sitemap locale
- T8 构建验收 + staging
### 未交付
- 无
### 偏差说明
- 无
## 简化决策
### 保持简单的关键选择
- 最简单可行方案:posts-en 独立集合 + TMT 管线脚本(幂等增量:未变文章不重译)+ /en/ 薄页面复用现有组件
- 暂不引入:runtime i18n 框架、cookie 语言记忆(切换即跳转,浏览器语言检测二期)
- 不做的抽象/配置化:不多语言框架化(zh/en 硬两语)
### 本轮明确不做的内容
- 上线切换(Phase 4)、Halo 退役(Phase 5)
## 变更边界
### 本轮主要改动模块
- 见 tasks.md 的 boundary 记录
### 明确未触碰的区域
- 上线切换(Phase 4)、Halo 退役(Phase 5)
## 验证证据
### 备注
- 机器证据:runs.jsonl(见验证范围的机器验证率)
## 验证范围
- 级别:package
- 机器验证率:8/8
- 规则:check 与 done 复用该范围;只有记录升级触发时才执行全项目检查
## 哲学生效证据
### 行为成效回填
- Development Record 行为门禁通过
### 一致性门禁回顾
- 验收面(checklist 或成功标准)已通过
## Git 记录
- 日期时间:2026-10-25 09:40
- 范围:Phase 3:双语骨架 + 腾讯 TMT 翻译管线
- 功能:T1 astro i18n 配置 + locale 管道;T2 UI 字典 + 组件串接;T3 语言切换组件(Header 中英互跳);T4 /en/ 页面骨架 + AI 译文标注组件;T5 TMT 翻译管线;T6 存量翻译执行 + 标注落页;T7 hreflang + 双语 RSS + sitemap locale;T8 构建验收 + staging
- 操作:提交 / 推送
- 成效:Development Record 行为门禁通过
- 提交:pending local commit
- 提交区间:44bfb23efbd0bea97ae058c06c54b08d38ad73df..4aa79fca065c6aa70fa8a8ce1bf62b2b383f661e
- 推送:not-run (push stage follows commit)
## AGENTS.md 增量提议
```diff
i18n 纪律:页面间不能传 props,双语页必须 body 提取为 components/pages/*Page 薄化(zh/en 各一层皮);页面搬目录后 import 相对深度全线要审;HTML 注释不可进 frontmatter 模块区;ts 端点首行误带 --- 会报 undefined:2:7。TMT 管线:1800+ 字符包服务端静默截断(CHUNK_LIMIT=1600 + ratio<0.3 检测 + 段边界二分);幂等 state 落 content/posts-en/.translation-state.json;locked:true 人工润色锁。翻译脚本幂等可重跑,新文章 push 后手动跑一次即可。
```
## 被拒绝的扩展提议
- 无
## 门禁证据
- check_spec_package.py exit 0
## 遗留事项
- 无;问题处置见下方结构化区块
## 问题处置
```json
{
"issues": [],
"version": 1
}
```
@@ -0,0 +1,8 @@
{"task": "task_0001", "cmd": "pnpm astro build", "exit": 0, "duration_s": 4.295, "stdout_tail_sha256": "258b6510265dd12dc6ed8735a3401809fea696ec4128ff4c3c7957434787528a", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:39:57+00:00"}
{"task": "task_0002", "cmd": "pnpm astro build && grep -q \"zh\" dist/index.html", "exit": 0, "duration_s": 4.095, "stdout_tail_sha256": "5252dbe3bc5801ef8c78152b058ae5e484b56f73313d1d0862a953a50c96e66b", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:40:02+00:00"}
{"task": "task_0003", "cmd": "pnpm astro build && grep -q 'href=\"/en/\"' dist/index.html", "exit": 0, "duration_s": 4.047, "stdout_tail_sha256": "b00fc1939ea9163faa87b8189ed82f6d53cc4ff4015e172acf3cd621755e6c33", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:40:06+00:00"}
{"task": "task_0004", "cmd": "pnpm astro build && test -f dist/en/index.html", "exit": 0, "duration_s": 9.479, "stdout_tail_sha256": "b607a66135561ec1eb2d65c5b0e92152ca208093e957cd2513b456ad5474d3bf", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:40:15+00:00"}
{"task": "task_0005", "cmd": "python3 scripts/translate/translate_posts.py --dry-run", "exit": 0, "duration_s": 0.067, "stdout_tail_sha256": "221074b3fe93cda975031e431ad7c9a4f9caba896b3170266391374ef06b0dc6", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:40:15+00:00"}
{"task": "task_0006", "cmd": "test $(ls content/posts-en/*.md 2>/dev/null | wc -l) -eq 6", "exit": 0, "duration_s": 0.003, "stdout_tail_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:40:15+00:00"}
{"task": "task_0007", "cmd": "pnpm astro build && grep -q hreflang dist/index.html && test -f dist/en/rss.xml", "exit": 0, "duration_s": 4.122, "stdout_tail_sha256": "2b0ed80c6ead9f0686bc4f24b1709d7eaeb0c0e8a34ff30f270d165d8bdaae05", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:40:19+00:00"}
{"task": "task_0008", "cmd": "bash infra/deploy/build.sh && test -f ~/docker_apps/blog/www-staging/en/index.html", "exit": 0, "duration_s": 5.51, "stdout_tail_sha256": "446db6c8e871aff5f7bbd4bec72a4f66a75446546a7b4e702bf1b12c334e6b72", "tree_fp": "50380ff9858de824ef43db6cc156bdbb9530e5e77dfcf8a6475bdb4a75d84837", "at": "2026-10-25T01:40:25+00:00"}
@@ -32,14 +32,14 @@
## 3. 功能范围
### 3.1 核心功能(MVP)
- [ ] T1 astro i18n 配置 + locale 管道
- [ ] T2 UI 字典 + 组件串接(Header/Footer/SearchDialog/图库/瞬间/关于)
- [ ] T3 语言切换组件(Header,中英互跳同路径 /en/ 前缀)
- [ ] T4 /en/ 页面骨架(index/archives 文章路由真实双语,其余页 UI 英文化+内容回退标注)
- [ ] T5 TMT 翻译管线(TC3 签名/分块/frontmatter 处理/.en.md 生成/锁定/dry-run)
- [ ] T6 存量 6 文翻译执行 + AI 译文标注组件
- [ ] T7 hreflang 双向 + 双语 RSS + sitemap locale 覆盖
- [ ] T8 构建验收(/en/ 路由全量产物 + 翻译产物抽检)
- [x] T1 astro i18n 配置 + locale 管道
- [x] T2 UI 字典 + 组件串接(Header/Footer/SearchDialog/图库/瞬间/关于)
- [x] T3 语言切换组件(Header,中英互跳同路径 /en/ 前缀)
- [x] T4 /en/ 页面骨架(index/archives 文章路由真实双语,其余页 UI 英文化+内容回退标注)
- [x] T5 TMT 翻译管线(TC3 签名/分块/frontmatter 处理/.en.md 生成/锁定/dry-run)
- [x] T6 存量 6 文翻译执行 + AI 译文标注组件
- [x] T7 hreflang 双向 + 双语 RSS + sitemap locale 覆盖
- [x] T8 构建验收(/en/ 路由全量产物 + 翻译产物抽检)
### 3.2 扩展功能
- 瞬间/图库 caption 的批量翻译(二期按需)
@@ -68,10 +68,10 @@
- 升级触发:只有改动构建链、部署脚本或 nginx 相关面时,才升级验证范围并记录理由
## 6. 成功标准与验证方式
- [ ] /en/ 与 /en/archives/{6 slug}/ 路由产物全存在 -> verify: task_0008
- [ ] 翻译管线幂等(重跑零新增 API 调用,锁文件/哈希比对) -> verify: task_0005
- [ ] AI 译文标注出现在 /en/ 文章页 -> verify: task_0006
- [ ] hreflang 双向 + en RSS 产出 -> verify: task_0007
- [x] /en/ 与 /en/archives/{6 slug}/ 路由产物全存在 -> verify: task_0008
- [x] 翻译管线幂等(重跑零新增 API 调用,锁文件/哈希比对) -> verify: task_0005
- [x] AI 译文标注出现在 /en/ 文章页 -> verify: task_0006
- [x] hreflang 双向 + en RSS 产出 -> verify: task_0007
## 7. 风险与约束
- TMT 签名实现错误(TC3 步骤繁)→ 脚本内自检模式(--selftest 打印签名串供比对官方文档) -> 管线任务内覆盖
@@ -28,12 +28,12 @@
- boundary: 新建 src/pages/en/{index.astro,archives/[...slug].astro,archives/index.astro,gallery,moments,about}(复用组件+locale prop);src/components/AiTranslatedBadge.astro;posts-en 集合定义进 content.config.ts
- verify: `pnpm astro build && test -f dist/en/index.html`
- [ ] T5 TMT 翻译管线
- [x] T5 TMT 翻译管线
- claim: op-artalk(mesh 车道,预约 scripts/translate/)
- boundary: 新建 scripts/translate/{tencent_tmt.py,translate_posts.py}:TC3-HMAC-SHA256 签名(--selftest 模式打印中间量)、段落分块(<2000 字符)、frontmatter 透传(title 翻译、locked:true 跳过)、.en.md 生成到 content/posts-en/、原文哈希记录防重译;凭据从宿主 0600 文件读(标签 Secert* 容错);不碰 src/、astro 配置
- verify: `python3 scripts/translate/translate_posts.py --dry-run`
- [ ] T6 存量翻译执行 + 标注落页
- [x] T6 存量翻译执行 + 标注落页
- depends-on: task_0004, task_0005
- claim: op-artalk(执行)+ orchestrator(验收)
- boundary: 真实调用 TMT 译 6 文入 content/posts-en/;/en/archives 模板挂 AiTranslatedBadge(T4 已备)
@@ -45,7 +45,7 @@
- boundary: BaseLayout 注入 hreflang 双向;src/pages/en/rss.xml.ts;sitemap 配置 i18n
- verify: `pnpm astro build && grep -q hreflang dist/index.html && test -f dist/en/rss.xml`
- [ ] T8 构建验收 + staging
- [x] T8 构建验收 + staging
- depends-on: task_0002, task_0003, task_0004, task_0006, task_0007
- claim: orchestrator
- boundary: build.sh 跑 staging;抽检 /en/ 三页(首页/一文/图库)渲染