Rainman Translate Book
Description
[English](README.md) | 中文 Claude Code Skill,使用并行 subagent 将整本书(PDF/DOCX/EPUB)翻译成任意语言。 > 本项目受 [claude_translater](https://github.com/wizlijun/claude_translater) 启发。原项目以 shell 脚本为入口,配合 Claude CLI 和多个步骤脚
Installation
claude install-skill https://github.com/deusyu/translate-book README
Rainman Translate Book
[English](README.md) | 中文
Claude Code Skill,使用并行 subagent 将整本书(PDF/DOCX/EPUB)翻译成任意语言。
本项目受 [claude_translater](https://github.com/wizlijun/claude_translater) 启发。原项目以 shell 脚本为入口,配合 Claude CLI 和多个步骤脚本完成分块翻译;本项目则将流程重构为 Claude Code Skill,使用 subagent 按 chunk 并行翻译,并引入 manifest 驱动的完整性校验,将续跑和多格式输出整合为更统一的流水线。由于项目结构和实现方式均与原项目不同,本项目为独立实现,而非 fork。
工作原理
输入文件 (PDF/DOCX/EPUB)
│
▼
Calibre ebook-convert → HTMLZ → HTML → Markdown
│
▼
拆分为 chunk(chunk0001.md, chunk0002.md, ...)
│ manifest.json 记录每个 chunk 的 SHA-256 hash
▼
并行 subagent 翻译(默认 8 路并发)
│ 每个 subagent:读取 1 个 chunk → 翻译 → 写入 output_chunk*.md
│ 分批执行,控制 API 速率
▼
校验(manifest hash 比对,源文件↔输出文件 1:1 匹配)
│
▼
合并 → Pandoc → HTML(含目录)→ Calibre → DOCX / EPUB / PDF
每个 chunk 由独立的 subagent 翻译,拥有全新的上下文窗口。这避免了单次会话翻译整本书时的上下文堆积和输出截断问题。
功能特性
- undefined
前置要求
- undefined
快速开始
1. 安装 Skill
**方式 A:npx(推荐)**
npx skills add deusyu/translate-book -a claude-code -g
**方式 B:ClawHub**
clawhub install translate-book
**方式 C:Git 克隆**
git clone https://github.com/deusyu/translate-book.git ~/.claude/skills/translate-book
2. 翻译一本书
在 Claude Code 中直接说:
translate /path/to/book.pdf to Chinese
或使用斜杠命令:
/translate-book translate /path/to/book.pdf to Japanese
Skill 自动处理完整流程 — 转换、拆分、并行翻译、校验、合并、生成所有输出格式。
3. 查看输出
所有文件在 `{book_name}_temp/` 目录下:
| 文件 | 说明 |
|---|---|
output.md |
合并后的翻译 Markdown |
book.html |
网页版,含浮动目录 |
book.docx |
Word 文档 |
book.epub |
电子书 |
book.pdf |
可打印 PDF |
流程详解
第一步:转换
python3 scripts/convert.py /path/to/book.pdf --olang zh
Calibre 将输入文件转为 HTMLZ,解压后转为 Markdown,再拆分为 chunk(每个约 6000 字符)。`manifest.json` 记录每个源 chunk 的 SHA-256 hash,用于后续校验。
第二步:翻译(并行 subagent)
Skill 分批启动 subagent(默认 8 路并发)。每个 subagent:
- undefined
如果运行中断,重新运行会跳过已有合法输出的 chunk。翻译失败的 chunk 会自动重试一次。
第三步:合并与构建
python3 scripts/merge_and_build.py --temp-dir book_temp --title "《译后书名》"
合并前校验:
- undefined
校验通过后:合并 → Pandoc 生成 HTML → 注入目录 → Calibre 生成 DOCX、EPUB、PDF。
**注意:** `{book_name}_temp/` 是单次翻译运行的工作目录。如果修改了标题、作者、输出语言、模板或图片资源,建议使用新的 temp 目录,或先删除已有的最终产物(`output.md`、`book*.html`、`book.docx`、`book.epub`、`book.pdf`)再重跑。
项目结构
| 文件 | 用途 |
|---|---|
SKILL.md |
Claude Code Skil |
Related Skills
Official Skills Repository Issues
Claude Documentation
Documentation community Doc Co-authoring
When user wants to write documentation, proposals, technical specs, decision docs, or similar structured contentGuide users through structured workflow for co-authoring documentation
Documentation official Docx
When user mentions Word doc, .docx, or requests professional documents with formattingCreate, edit, and analyze Word documents with tracked changes, comments, and formatting
Documentation official Extract text, create PDFs, merge/split documents, and handle forms
Documentation official Pptx
When a .pptx file is involved in any way, or user mentions deck, slides, or presentationCreate, edit, and analyze PowerPoint presentations with layouts and templates
Documentation official Xlsx
When a spreadsheet file is the primary input or output (.xlsx, .xlsm, .csv, .tsv)Create, edit, and analyze Excel spreadsheets with formulas, formatting, and visualization
Documentation official