From learn-skills
翻译 EPUB 电子书文件,同时保留格式、结构和元数据。当用户需要翻译 .epub 文件时使用此技能,支持:(1) 完整书籍翻译,(2) 章节选择性翻译,(3) 翻译前样本预览,(4) 自定义翻译规则(保留术语、人名等),(5) 多语言互译
How this skill is triggered — by the user, by Claude, or both
Slash command
/learn-skills:epub-translatorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
将 EPUB 电子书从一种语言翻译为另一种语言,同时保持原始格式、章节结构和元数据完整。
将 EPUB 电子书从一种语言翻译为另一种语言,同时保持原始格式、章节结构和元数据完整。
基本用法:
将这个 EPUB 从英文翻译成中文
带自定义规则:
翻译成中文,保留所有人名和地名的英文原文
读取用户上传的 EPUB 文件:
const fileData = await window.fs.readFile(filename);
EPUB 是 ZIP 格式,包含:
META-INF/container.xml - 指向内容清单content.opf - 元数据和文件清单toc.ncx - 目录OEBPS/, EPUB/ 或 text/ 目录)提取并展示:
询问用户:
翻译第一章或前 1000 字,展示给用户确认翻译风格和质量。
逐章翻译内容:
进度更新:大型书籍每完成 2-3 章更新一次进度
content.opf 元数据(添加语言标记)检查:
目录也要进行翻译。
目录文件名一般为:toc.ncx,只需要翻译<text></text>标签内的文本。
<p class="text">Hello</p> → <p class="text">你好</p>建立术语表,确保:
使用 JSZip 处理 EPUB:
// 解压 EPUB
const zip = await JSZip.loadAsync(fileData);
// 读取文件
const content = await zip.file('OEBPS/chapter1.html').async('string');
// 修改后重新打包
zip.file('OEBPS/chapter1.html', translatedContent);
const newEpub = await zip.generateAsync({type: 'blob'});
分离文本与标签:
// 提取文本节点,保留标签
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
// 遍历文本节点翻译
function translateTextNodes(node) {
if (node.nodeType === Node.TEXT_NODE) {
node.textContent = translate(node.textContent);
} else {
node.childNodes.forEach(translateTextNodes);
}
}
在 content.opf 中添加语言标记:
<!-- 假设源文件被翻译为了中文,就插入zh -->
<dc:language>zh</dc:language>
<meta property="dcterms:modified">2026-01-20T12:00:00Z</meta>
书中已有多种语言时:
超过 5MB 或 50 章的书籍:
无法处理:
质量提醒: 大型文献(学术书籍、技术手册)建议用户审核样本章节,确认专业术语翻译准确。
示例 1:基础翻译
用户:将这本英文小说翻译成中文
助手:好的,让我先分析这个 EPUB 文件...
发现:
- 书名:The Great Gatsby
- 作者:F. Scott Fitzgerald
- 章节:9 章
- 约 47,000 词
在翻译全书前,我先翻译第一章给您看看翻译风格:
[展示第一章样本]
翻译风格如何?需要调整吗?
示例 2:自定义规则
用户:翻译成日语,但保留所有魔法咒语为英文原文
助手:明白了,我会:
1. 将叙述和对话翻译成日语
2. 识别魔法咒语(通常为斜体或特殊标记)
3. 保留这些咒语的英文原文
开始翻译...
生成可下载的 .epub 文件:
[原书名]_[目标语言].epubnpx claudepluginhub leeyorke/leeyorke-skills --plugin leeyorke-skillsCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.