Translate or localize EPUB files into a target language while preserving XHTML structure, validating with epubcheck diff against the original, and safely rebuilding outputs with atomic replace and rollback-on-failure. Use when asked to translate an EPUB, repair generated-only EPUB validation errors, or run repeatable EPUB localization workflow steps.
Use this skill to run a repeatable EPUB localization workflow with low rework risk. Always preserve XHTML structure, validate generated EPUB against the original EPUB, and avoid leaving scattered backup files in the workspace root.
Collect and confirm these inputs before execution:
input_epub: source EPUB pathoutput_epub: translated EPUB pathtarget_language: language code or language label (default: ja)scope: core or all (default: core)keep_failure_backup: true or false (default: true)To reduce approval prompts and keep execution smooth:
tmp/run-<timestamp>/.epubcheck; if missing, pause and ask before installing.tmp/run-*/rollback/ only.*.bak-* files in normal success flow.Use this flow:
tmp/run-<timestamp>/.tmp/run-<timestamp>/unpacked/.todo.md when translating only specific chapters/files.epubcheck results between original and generated EPUB.Maintain todo.md as a live progress board for resumability:
Current phaseChapter progress: <done>/<total>Current chapterLast updated[ ] / [x])Update todo.md at:
Use core scope by default:
ch*.xhtml, fm.xhtml, toc.xhtml, nav.xhtml, pref01-04.xhtml, appendix.xhtml.references.xhtml.references.xhtml.index.xhtml unchanged unless user explicitly asks to translate index entries.Use all scope only when user explicitly requests full translation.
When user requests chapter-only translation without extending scope:
scope as core or all (no new scope type).OEBPS/xhtml/ch01.xhtml) in todo.md.Read references/translation-rules.md before editing content.
Hard constraints:
id, class, href, epub:type, numbers, or anchor IDs.id="page_...".Style and terminology constraints:
<translated term> (<source term>)).Use this strategy to reduce delays and avoid rework:
1 chapter = 1 worker.1-120, 121-260, 261+).xmllint --noout passesWhen interruption happens:
completed / not completed, and exact range).*.bak_codex from final packaging.After each translated chunk, run all gates:
xmllint --noout <file>page_*, section ids referenced by nav/index/toc)allowed and suspicioussuspicious_count > 0Important: Missing pagebreak IDs often creates RSC-012 errors.
Read references/validation-policy.md before final acceptance.
Validation policy:
epubcheck on original EPUB.epubcheck on generated EPUB.0.Never replace output directly.
*.tmp first.*.tmp, *.ids, *.pageids, *.bak_codex must be absent from unpacked source).mv) only after successful build.tmp/run-<timestamp>/rollback/.keep_failure_backup=true.*.bak-* in workspace root during normal success path.Use these scripts from scripts/:
scripts/check_epub.shscripts/repackage_epub.shrun-dir/unpacked.mimetype first and stored.*.tmp, *.ids, *.pageids, *.bak_codex) by default.scripts/cleanup_run.shscripts/residual_english_gate.shallowed and suspicious.scripts/check_allowed_changes.sh--allowed-file.When Git is available:
git rev-parse --is-inside-work-tree.Accept only when all items pass:
SKILL.md includes workflow, worker strategy, interruption recovery, quality gates, validation diff policy, allowed-change gate, and safe replace policy.scripts/check_epub.sh, scripts/repackage_epub.sh, scripts/cleanup_run.sh, scripts/residual_english_gate.sh, and scripts/check_allowed_changes.sh exist and run.quick_validate.py passes.*.bak-* in workspace root.