deusyu/translate-book
Agent skill for Codex, Claude Code, and OpenClaw that translates entire books (PDF/DOCX/EPUB) into any language using parallel subagents.
Rainman Translate Book – AI‑assisted whole‑book translation
What it does – Turns a PDF, DOCX, EPUB or Markdown book into a translated version in any language. The pipeline:
- Convert the source file to Markdown (via Calibre or a layout‑aware parser).
- Chunk the Markdown into ~6 k‑character pieces and record a SHA‑256 manifest for each chunk.
- Translate each chunk in parallel using 8 independent LLM sub‑agents (Codex, Claude Code or OpenClaw). Each sub‑agent gets a fresh context window plus a short read‑only excerpt from the neighbouring chunks and a glossary of key terms to keep terminology consistent.
- Validate the outputs against the manifest, then merge the translated chunks.
- Build final artefacts – HTML with a floating table of contents, DOCX, EPUB and PDF – via Pandoc and Calibre.
Key features
- Parallel sub‑agents (default 8) avoid context overflow and speed up translation.
- Chunk‑level resumable runs; a
run_state.jsonlets you restart without re‑translating already‑done pieces. - Glossary system that extracts proper nouns/terms from a sample of chunks, lets you edit a
glossary.json, and injects a term‑table into each translation prompt. - Manifest‑based integrity checks (SHA‑256) guarantee that stale or corrupted chunks are not merged.
- Supports many target languages (Chinese, Japanese, Korean, French, German, Spanish, etc.) and multiple output formats.
- Optional pre‑processing for formula‑heavy PDFs using MinerU or Marker, preserving LaTeX math.
How to use
- Install the skill for your agent runtime (
npx skills add deusyu/translate-book -a codexor the equivalent for Claude Code/OpenClaw). - In the agent’s CLI or chat, issue a command like
translate /path/to/book.pdf to Chinese(or use the slash command/translate‑book …). - The skill creates a temporary working directory (
{book}_temp/) and, after the run finishes, you’ll find:output.md– merged translated markdownbook.html,book.docx,book.epub,book.pdf– the final formats.
Prerequisites – Calibre (ebook-convert), Pandoc, Python 3 with pypandoc (and optionally beautifulsoup4), and an installed Codex/Claude Code/OpenClaw runtime.
Project layout – The repository contains the skill definition (SKILL.md) and a set of Python scripts handling conversion, manifest management, glossary handling, chunk context, run planning, merging and final build. Test assets are provided under tests/baselines/.
Who it’s for – Researchers, translators, or anyone who needs to translate whole books quickly while keeping terminology consistent, and who already works with LLM‑based agents.
Related
- Project
- Project
- Project
- Project
- Project