此文件为 Claude Code (claude.ai/code) 在本代码库中工作时提供指导。
这是一个EPUB翻译项目,用于将英文书籍转换为中文。系统从EPUB档案中提取HTML文件,使用各种AI翻译API(DeepSeek、SiliconFlow等)处理和翻译内容,并在SQLite数据库中维护翻译进度。
/code/
目录中的主要翻译脚本,处理批量翻译并跟踪进度/Ops/
子目录中translate_epub_v4(单线程版本)V3.py
- 原始稳定的单线程翻译脚本translate_epub_v4_optimized.py
- 推荐 优化版本,具有批量数据库操作和翻译缓存translate_epub.py
- 带异步处理的多线程版本main.py
- 简单的API测试脚本META-INF/
、Ops/
(HTML内容)、images/
p34
类)# 推荐:带缓存和批量操作的优化版本(智能跳过已翻译文件)
python code/translate_epub_v4_optimized.py
# 强制重新翻译所有文件(覆盖已存在的文件)
python code/translate_epub_v4_optimized.py --force
# 查看所有可用选项
python code/translate_epub_v4_optimized.py --help
# 原始稳定版本
python code/translate_epub_v4(单线程版本)V3.py
# 多线程版本
python code/translate_epub.py
# 性能对比测试
python code/performance_test.py
# 检查翻译进度
sqlite3 translation_progress.db "SELECT * FROM translation_progress;"
# 详细文件进度
sqlite3 translation_progress.db "SELECT file_path, ROUND(processed_lines * 100.0 / total_lines, 2) as progress_percent, status, last_updated FROM file_progress;"
# 翻译组进度
sqlite3 translation_progress.db "SELECT file_path, group_index, status, updated_at FROM group_progress ORDER BY file_path, group_index;"
# 检查翻译缓存效果(优化版本)
sqlite3 translation_progress.db "SELECT COUNT(*) as cached_translations, AVG(access_count) as avg_reuse FROM translation_cache;"
# 安装所需包
pip install -r code/requirements.txt
系统支持在code/config.yaml
中配置多个AI翻译提供商:
deepseek-chat
模型)translation_progress
: 总体进度跟踪file_progress
: 按文件翻译状态group_progress
: 翻译组/批次状态translation_cache
: 缓存的翻译(仅优化版本)line_progress
: 单行翻译跟踪/Ops/
子目录下*_translated/
目录/code/归档/
中/code/
目录中/cache/
目录中(优化版本)translate_epub_v4_optimized.py
提供最佳性能config_optimized.yaml
中根据硬件调整batch_commit_size
initial_line_count
: 每组处理行数,增大可提速但可能影响质量cache_size
: 内存缓存大小,根据可用内存调整batch_commit_size
: 数据库批量提交大小,较大值提升性能# 检查缓存统计
sqlite3 translation_progress.db "SELECT * FROM translation_cache LIMIT 10;"
# 查看错误日志
tail -f translation.log
# 重置进度(谨慎使用)
sqlite3 translation_progress.db "DELETE FROM file_progress WHERE status != 'completed';"
system
消息内容使用优化版本相比原版本的典型改进:
提示: 对于新项目,建议直接使用translate_epub_v4_optimized.py
以获得最佳性能和用户体验。