Document Bilingual Converter is a fully automated document translation toolkit that translates PPT, Word, and PDF files bidirectionally between Chinese and English while strictly preserving the original layout, formatting, fonts, colors, and embedded objects.
No glossary files. No manual post-editing. Translation is powered by LLM. Layout is preserved by the document engine.
One workflow:
# Extract → AI translates → Apply → Done
python doc_converter.py presentation.pptx --source zh --target en --font "Times New Roman"| Pillar | Role | Detail |
|---|---|---|
| Layout Engine | Format preservation | Shape positions, sizes, colors untouched |
| LLM Translator | Text translation | Bidirectional zh↔en, no hardcoded glossary |
| OLE Handler | Embedded objects | Excel tables in PPT, EMF preview images |
| Format | Translation Granularity | Layout | Embedded Objects |
|---|---|---|---|
| PPT (.pptx) | Run-level (zh↔en) | Full | OLE tables, EMF previews |
| Word (.docx) | Run-level (zh↔en) | Full | Tables |
| PDF (.pdf) | Span-level (zh↔en) | Approximate | None |
# 1. Install dependencies (one time)
pip install python-pptx python-docx openpyxl olefile
pip install PyMuPDF # optional, for PDF support
# 2. Translate a document (Chinese → English)
python doc_converter.py input.pptx --source zh --target en --font "Times New Roman"
# 3. Translate a document (English → Chinese)
python doc_converter.py input.pptx --source en --target zh --font "微软雅黑"
# 4. Extract texts only (for manual review)
python doc_converter.py input.pptx --extract-only --source zh > texts.jsonpython doc_converter.py <input> [options]
Options:
-o, --output PATH Output file path
--source LANG Source language: zh or en (default: zh)
--target LANG Target language: zh or en (default: en)
--font "Font Name" Apply font to translated text
--start-slide N PPT: start slide for font application (default: 1)
--translations FILE JSON file with pre-made {source: target} mappings
--extract-only Only extract texts and print as JSON
| Translation Engine | Strengths |
|---|---|
| AI-Driven (recommended) | AI translates each text snippet intelligently — preserves model numbers, brand names, technical terms |
| CLI API Mode | Calls OpenAI-compatible API via env vars — batch translation |
| Manual JSON File | Pre-made {source: target} dictionary — full control |
| Element | What Happens |
|---|---|
| Shape position & size | Never changed |
| Font family & size | Original kept; optionally apply target font |
| Bold / italic / color | Preserved at run level |
| Text alignment | Preserved |
| Tables & merge cells | Structure preserved; cells translated |
| Embedded Excel (OLE) | Extracted → translated → re-embedded |
Drop SKILL.md into your agent's skills directory (works with OpenClaw, Claude Code, Codex, Gemini CLI):
# OpenClaw
cp SKILL.md ~/.openclaw/workspace/skills/doc-bilingual-converter/
# Claude Code / Trae IDE
cp SKILL.md <project>/.claude/skills/doc-bilingual-converter/
# Codex CLI
cp SKILL.md ~/.codex/skills/doc-bilingual-converter/User: "把这个PPT翻译成英文,保留所有排版"
|
Agent runs: python doc_converter.py input.pptx --extract-only --source zh
|
Agent translates: each extracted text snippet
|
Agent applies: converter.apply_translations(translations)
|
Agent finalizes: converter.fix_layout() + converter.apply_font("Times New Roman")
|
User opens: output_EN.pptx → translated + layout intact
- Python >= 3.10
- python-pptx, python-docx, openpyxl, olefile
- PyMuPDF (optional, for PDF support)
MIT (c) 2026
Document Bilingual Converter 是一个全自动文档翻译工具,支持 PPT、Word、PDF 三种格式的中文 ↔ 英文双向翻译,同时完整保留原始排版、字体、颜色和内嵌对象。
无需词表文件,无需手动后处理。翻译由 LLM 驱动,排版由文档引擎保证。
一条命令:
# 提取 → AI翻译 → 应用 → 完成
python doc_converter.py presentation.pptx --source zh --target en --font "Times New Roman"| 支柱 | 角色 | 说明 |
|---|---|---|
| 排版引擎 | 格式保留 | 形状位置、大小、颜色完全不动 |
| LLM 翻译器 | 文本翻译 | 中英双向,无硬编码词表 |
| OLE 处理器 | 内嵌对象 | PPT 中的 Excel 表格、EMF 预览图 |
| 格式 | 翻译粒度 | 排版保留 | 内嵌对象 |
|---|---|---|---|
| PPT (.pptx) | Run 级别(zh↔en) | 完整 | OLE 表格、EMF 预览 |
| Word (.docx) | Run 级别(zh↔en) | 完整 | 表格 |
| PDF (.pdf) | Span 级别(zh↔en) | 近似 | 无 |
# 1. 一次性安装依赖
pip install python-pptx python-docx openpyxl olefile
pip install PyMuPDF # 可选,用于 PDF 支持
# 2. 翻译文档(中文 → 英文)
python doc_converter.py input.pptx --source zh --target en --font "Times New Roman"
# 3. 翻译文档(英文 → 中文)
python doc_converter.py input.pptx --source en --target zh --font "微软雅黑"
# 4. 仅提取文本(用于审阅)
python doc_converter.py input.pptx --extract-only --source zh > texts.jsonpython doc_converter.py <input> [options]
Options:
-o, --output PATH 输出文件路径
--source LANG 源语言:zh 或 en(默认 zh)
--target LANG 目标语言:zh 或 en(默认 en)
--font "Font Name" 翻译后应用的字体
--start-slide N PPT: 字体起始页(默认 1)
--translations FILE JSON 翻译映射文件
--extract-only 仅提取文本,输出 JSON
| 翻译方式 | 优势 |
|---|---|
| AI 驱动(推荐) | AI 智能翻译每段文本 — 自动保留型号、品牌名、技术术语 |
| CLI API 模式 | 通过环境变量调用 OpenAI 兼容 API — 批量翻译 |
| 手动 JSON 文件 | 预制的 {原文: 译文} 字典 — 完全可控 |
| 元素 | 处理方式 |
|---|---|
| 形状位置和大小 | 完全不改变 |
| 字体和字号 | 保留原始(可选应用目标语言字体) |
| 加粗/斜体/颜色 | Run 级别精确保留 |
| 文本对齐方式 | 完整保留 |
| 表格和合并单元格 | 结构保留,内容翻译 |
| 嵌入的 Excel(OLE) | 提取 → 翻译 → 重新嵌入 |
将 SKILL.md 放入 AI Agent 的 skills 目录(支持 OpenClaw、Claude Code、Codex、Gemini CLI):
# OpenClaw
cp SKILL.md ~/.openclaw/workspace/skills/doc-bilingual-converter/
# Claude Code / Trae IDE
cp SKILL.md <project>/.claude/skills/doc-bilingual-converter/
# Codex CLI
cp SKILL.md ~/.codex/skills/doc-bilingual-converter/用户:"把这个PPT翻译成英文,保留所有排版"
|
Agent 执行:python doc_converter.py input.pptx --extract-only --source zh
|
Agent 翻译:每条提取的文本
|
Agent 应用:converter.apply_translations(translations)
|
Agent 收尾:converter.fix_layout() + converter.apply_font("Times New Roman")
|
用户打开:output_EN.pptx → 翻译完成 + 排版不变
- Python >= 3.10
- python-pptx, python-docx, openpyxl, olefile
- PyMuPDF(可选,用于 PDF 支持)
MIT (c) 2026