feat: Release v0.10 - Modular Architecture & External Config

- Refactor codebase into src/ (preprocessing, translation, assembly)
- Add pipeline/ scripts for individual stages
- Externalize configuration to config/config.yaml
- Fix Cover Image preservation
- Update documentation and manuals
This commit is contained in:
谭凯
2026-01-31 22:49:44 +08:00
parent 9ef82393be
commit 7a93c52b42
306 changed files with 30313 additions and 1071 deletions
+6 -89
View File
@@ -1,97 +1,14 @@
# EPUB 双语翻译程序 v0.07
# EPUB Bilingual Translator
一个基于 OpenRouter/OpenAI API 的 EPUB 双语翻译工具,采用**全局编号系统**和**真并发翻译**。
Current Version: 0.10 (In Development)
Architecture: v2 (Modular)
## ✨ 核心特性
### 🎯 全局编号系统
- **每个段落分配全局唯一ID**(格式:`p_0001`, `p_0002`...
- **ID贯穿全流程**:提取 → 翻译 → 组装
- **精确对应保证**:绝不出现中英文错行问题
### ⚡ 真并发翻译
- **asyncio.gather 并发执行**:高效利用 API 速率限制
- **智能速率控制**:基于 Token 桶的 RateLimiter
- **实时进度显示**:Rich 进度条显示翻译状态
- **断点续传**:自动记录进度,随时中断随时继续
### 🛡️ 安全与稳定
- **环境隔离**:支持 `.env` 配置,API Key 不落地
- **鲁棒重试**:集成 `tenacity` 处理网络波动
- **缓存系统**:基于 Hash 的持久化缓存,跨天复用
### 🎨 极致排版
- **盘古之白**:自动在中文与西文数字间添加空格
- **样式注入**:注入专用 CSS 优化阅读体验
## 🚀 快速开始
### 1. 安装依赖
## Usage
```bash
pip install -r requirements.txt
```
### 2. 配置环境
复制 `.env` 模板并填入你的 API Key
```bash
# .env 文件
V3_API_KEY=sk-xxxxxx
OPENROUTER_API_KEY=sk-or-xxxxxx
```
### 3. 开始翻译
```bash
# 默认使用 OpenRouter
python main.py input/book.epub
# 使用 V3 Provider
python main.py input/book.epub -p v3
# 测试模式(只翻译前3个块)
python main.py input/book.epub --test
```
## 📂 目录结构
## Architecture
```
.
├── config/ # 配置文件
│ ├── config.json # 主配置
│ └── prompts.json # 提示词模板
├── input/ # 输入 EPUB 目录
├── output/ # 输出 EPUB 目录
├── cache/ # 缓存目录 (Manifest, Translations)
├── logs/ # 运行日志
└── src/ # 源代码
```
## ⚙️ 核心配置 (config.json)
```json
{
"translation": {
"chunk_size": 5000,
"temperature": 0.3
},
"providers": {
"v3": {
"base_url": "https://api.gpt.ge/v1",
"models": { "fast": "gpt-4o-mini" },
"rate_limits": { "requests_per_minute": 500 }
}
}
}
```
## 📄 许可证
MIT License
---
**版本**: v0.07
**更新**: 2026-01-13
See `doc/architecture_flow.md` for details.