Translate a Japanese PowerPoint (.pptx) to English with python-pptx: Grouped Shapes, Tables, Speaker Notes, and an Overflow Check
说明与用途
脚本将日语 PowerPoint 翻译为英文,处理分组形状、表格、演讲者备注,并检查文本溢出。
问题
Simple python-pptx translation loops miss grouped shapes, tables and speaker notes, and translated text can overflow its boxes.
结果
The script processes all text containers, including grouped shapes, tables, and speaker notes, and performs an overflow check, producing a fully translated deck with no residual Japanese and no text overflow.
工作流
- Extract every text container with walk_shapes, yielding key, text_frame, width, height.
- Export each text frame’s content to a CSV with a stable key.
- Translate the CSV entries using an offline glossary.
- Apply the translated text back to the corresponding text frames.
- Check each text frame for leftover Japanese and for overflow against its width and height.
- Flag any overflowed text for manual review.
- Render the resulting deck with LibreOffice to verify layout.
证据
Simple python‑pptx translation loops miss grouped shapes, tables and speaker notes. This one exports every Japanese paragraph to a CSV you can review, writes the English back, then checks for leftover Japanese and text that no longer fits.
The code below was run on October 25, 2026, with python‑pptx 1.0.2 and Python 3.13.5 on a small Japanese sample deck we made up for testing.
The before/after check was rendered with LibreOffice, not PowerPoint, so spacing in PowerPoint may differ a little.
- 记录日期: 2026-10-25T14:41:25.751Z