{"id":47453635,"url":"https://github.com/deusyu/translate-book","last_synced_at":"2026-04-07T02:01:18.852Z","repository":{"id":344617914,"uuid":"1182353280","full_name":"deusyu/translate-book","owner":"deusyu","description":"Claude Code skill that translates entire books (PDF/DOCX/EPUB) into any language using parallel subagents","archived":false,"fork":false,"pushed_at":"2026-04-04T14:37:11.000Z","size":76,"stargazers_count":588,"open_issues_count":4,"forks_count":57,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-04T16:57:43.504Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deusyu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"deusyu"}},"created_at":"2026-03-15T12:04:50.000Z","updated_at":"2026-04-04T14:37:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/deusyu/translate-book","commit_stats":null,"previous_names":["deusyu/translate-book"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deusyu/translate-book","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deusyu%2Ftranslate-book","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deusyu%2Ftranslate-book/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deusyu%2Ftranslate-book/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deusyu%2Ftranslate-book/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deusyu","download_url":"https://codeload.github.com/deusyu/translate-book/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deusyu%2Ftranslate-book/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31496769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"online","status_checked_at":"2026-04-07T02:00:07.164Z","response_time":105,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-23T18:00:33.561Z","updated_at":"2026-04-07T02:01:18.845Z","avatar_url":"https://github.com/deusyu.png","language":"Python","readme":"# Rainman Translate Book\n\nEnglish | [中文](README.zh-CN.md)\n\nClaude Code skill that translates entire books (PDF/DOCX/EPUB) into any language using parallel subagents.\n\n\u003e Inspired by [claude_translater](https://github.com/wizlijun/claude_translater). The original project uses shell scripts as its entry point, coordinating the Claude CLI with multiple step scripts to perform chunked translation. This project restructures the workflow as a Claude Code Skill, using subagents to translate chunks in parallel, with manifest-driven integrity checks, resumable runs, and multi-format output unified into a single pipeline. As the project structure and implementation differ significantly from the original, this is an independent project rather than a fork.\n\n---\n\n## How It Works\n\n```\nInput (PDF/DOCX/EPUB)\n  │\n  ▼\nCalibre ebook-convert → HTMLZ → HTML → Markdown\n  │\n  ▼\nSplit into chunks (chunk0001.md, chunk0002.md, ...)\n  │  manifest.json tracks chunk hashes\n  ▼\nParallel subagents (8 concurrent by default)\n  │  each subagent: read 1 chunk → translate → write output_chunk*.md\n  │  batched to respect API rate limits\n  ▼\nValidate (manifest hash check, 1:1 source↔output match)\n  │\n  ▼\nMerge → Pandoc → HTML (with TOC) → Calibre → DOCX / EPUB / PDF\n```\n\nEach chunk gets its own independent subagent with a fresh context window. This prevents context accumulation and output truncation that happen when translating a full book in a single session.\n\n## Features\n\n- **Parallel subagents** — 8 concurrent translators per batch, each with isolated context\n- **Resumable** — chunk-level resume; already-translated chunks are skipped on re-run (for metadata/template changes, use a fresh run)\n- **Manifest validation** — SHA-256 hash tracking prevents stale or corrupt outputs from being merged\n- **Multi-format output** — HTML (with floating TOC), DOCX, EPUB, PDF\n- **Multi-language** — zh, en, ja, ko, fr, de, es (extensible)\n- **PDF/DOCX/EPUB input** — Calibre handles the conversion heavy lifting\n\n## Prerequisites\n\n- **Claude Code CLI** — installed and authenticated\n- **Calibre** — `ebook-convert` command must be available ([download](https://calibre-ebook.com/))\n- **Pandoc** — for HTML↔Markdown conversion ([download](https://pandoc.org/))\n- **Python 3** with:\n  - `pypandoc` — required (`pip install pypandoc`)\n  - `beautifulsoup4` — optional, for better TOC generation (`pip install beautifulsoup4`)\n\n## Quick Start\n\n### 1. Install the skill\n\n**Option A: npx (recommended)**\n\n```bash\nnpx skills add deusyu/translate-book -a claude-code -g\n```\n\n**Option B: ClawHub**\n\n```bash\nclawhub install translate-book\n```\n\n**Option C: Git clone**\n\n```bash\ngit clone https://github.com/deusyu/translate-book.git ~/.claude/skills/translate-book\n```\n\n\n### 2. Translate a book\n\nIn Claude Code, say:\n\n```\ntranslate /path/to/book.pdf to Chinese\n```\n\nOr use the slash command:\n\n```\n/translate-book translate /path/to/book.pdf to Japanese\n```\n\nThe skill handles the full pipeline automatically — convert, chunk, translate in parallel, validate, merge, and build all output formats.\n\n### 3. Find your outputs\n\nAll files are in `{book_name}_temp/`:\n\n| File | Description |\n|------|-------------|\n| `output.md` | Merged translated Markdown |\n| `book.html` | Web version with floating TOC |\n| `book.docx` | Word document |\n| `book.epub` | E-book |\n| `book.pdf` | Print-ready PDF |\n\n## Pipeline Details\n\n### Step 1: Convert\n\n```bash\npython3 scripts/convert.py /path/to/book.pdf --olang zh\n```\n\nCalibre converts the input to HTMLZ, which is extracted and converted to Markdown, then split into chunks (~6000 chars each). A `manifest.json` records the SHA-256 hash of each source chunk for later validation.\n\n### Step 2: Translate (parallel subagents)\n\nThe skill launches subagents in batches (default: 8 concurrent). Each subagent:\n\n1. Reads one source chunk (e.g. `chunk0042.md`)\n2. Translates to the target language\n3. Writes the result to `output_chunk0042.md`\n\nIf a run is interrupted, re-running skips chunks that already have valid output files. Failed chunks are retried once automatically.\n\n### Step 3: Merge \u0026 Build\n\n```bash\npython3 scripts/merge_and_build.py --temp-dir book_temp --title \"《translated title》\"\n```\n\nBefore merging, the script validates:\n- Every source chunk has a corresponding output file (1:1 match)\n- Source chunk hashes match the manifest (no stale outputs)\n- No output files are empty\n\nThen: merge → Pandoc HTML → inject TOC → Calibre generates DOCX, EPUB, PDF.\n\n**Note:** `{book_name}_temp/` is a working directory for a single translation run. If you change the title, author, output language, template, or image assets, either use a fresh temp directory or delete the existing final artifacts (`output.md`, `book*.html`, `book.docx`, `book.epub`, `book.pdf`) before re-running.\n\n## Project Structure\n\n| File | Purpose |\n|------|---------|\n| `SKILL.md` | Claude Code skill definition — orchestrates the full pipeline |\n| `scripts/convert.py` | PDF/DOCX/EPUB → Markdown chunks via Calibre HTMLZ |\n| `scripts/manifest.py` | Chunk manifest: SHA-256 tracking and merge validation |\n| `scripts/merge_and_build.py` | Merge chunks → HTML → DOCX/EPUB/PDF |\n| `scripts/calibre_html_publish.py` | Calibre wrapper for format conversion |\n| `scripts/template.html` | Web HTML template with floating TOC |\n| `scripts/template_ebook.html` | Ebook HTML template |\n\n## Troubleshooting\n\n| Problem | Solution |\n|---------|----------|\n| `Calibre ebook-convert not found` | Install Calibre and ensure `ebook-convert` is in PATH |\n| `Manifest validation failed` | Source chunks changed since splitting — re-run `convert.py` |\n| `Missing source chunk` | Source file deleted — re-run `convert.py` to regenerate |\n| Incomplete translation | Re-run the skill — it resumes from where it stopped |\n| Changed title/template/assets but output didn't update | Delete existing `output.md`, `book*.html`, `book.docx`, `book.epub`, `book.pdf` from the temp dir, then re-run `merge_and_build.py` |\n| `output.md exists but manifest invalid` | Stale output — the script auto-deletes and re-merges |\n| PDF generation fails | Ensure Calibre is installed with PDF output support |\n\n## Star History\n\nIf you find this project helpful, please consider giving it a Star ⭐!\n\n[![Star History Chart](https://api.star-history.com/svg?repos=deusyu/translate-book\u0026type=Date)](https://star-history.com/#deusyu/translate-book\u0026Date)\n\n## Sponsor\n\nIf this project saves you time, consider sponsoring to keep it maintained and improved.\n\n[![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-pink?logo=github)](https://github.com/sponsors/deusyu)\n\n## License\n\n[MIT](LICENSE)\n","funding_links":["https://github.com/sponsors/deusyu"],"categories":["🧠 Agent Skills","Sponsors ❤️"],"sub_categories":["Community Skills"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeusyu%2Ftranslate-book","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeusyu%2Ftranslate-book","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeusyu%2Ftranslate-book/lists"}