pdf-translator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePDF Translator Skill
PDF Translator Skill
Instructions
说明
Follow these steps to translate a PDF file:
- Identify the PDF File: Confirm the path to the PDF file the user wants to translate. If the path is relative, resolve it to an absolute path.
- Extract Text: Use the script located in the
extract_text.pydirectory of this skill to extract text from the PDF.scripts- Command:
python3 skills/pdf-translator/scripts/extract_text.py <path_to_pdf> - Note: Ensure you are using the correct python environment (e.g., if applicable, or just
.venv/bin/pythonif dependencies are installed globally).python3
- Command:
- Translate Content:
- Read the output from the extraction step.
- Translate the extracted text into the target language requested by the user (default to the user's primary language or English if ambiguous).
- Maintain the original structure (headings, paragraphs) as much as possible using Markdown formatting.
- Save Output:
- Create a new Markdown file with the translated content.
- Filename format: .
<original_filename>_translated.md - Notify the user of the output file location.
请按照以下步骤翻译PDF文件:
- 确定PDF文件:确认用户想要翻译的PDF文件路径。如果是相对路径,请将其解析为绝对路径。
- 提取文本:使用本技能目录下的
scripts脚本从PDF中提取文本。extract_text.py- 命令:
python3 skills/pdf-translator/scripts/extract_text.py <path_to_pdf> - 注意:确保使用正确的Python环境(例如,适用的话使用,如果依赖已全局安装则直接使用
.venv/bin/python)。python3
- 命令:
- 翻译内容:
- 读取提取步骤的输出内容。
- 将提取的文本翻译为用户要求的目标语言(如果不明确,则默认使用用户的主要语言或英语)。
- 尽可能使用Markdown格式保留原文结构(标题、段落)。
- 保存输出:
- 创建一个包含翻译内容的新Markdown文件。
- 文件名格式:。
<original_filename>_translated.md - 通知用户输出文件的位置。
Examples
示例
User: "Translate the file papers/deep_learning.pdf to Chinese."
Claude:
- Locates .
papers/deep_learning.pdf - Runs:
python3 skills/pdf-translator/scripts/extract_text.py papers/deep_learning.pdf - Translates the extracted text to Chinese.
- Saves the result to .
papers/deep_learning_translated.md - Responds: "I have translated the PDF and saved it to ."
papers/deep_learning_translated.md
User: "Help me read this manual.pdf"
Claude:
- Locates .
manual.pdf - Runs extraction script.
- Translates/Summarizes based on user intent (if "read" implies understanding, a translation or summary might be appropriate).
用户:“将文件papers/deep_learning.pdf翻译为中文。”
Claude:
- 定位到。
papers/deep_learning.pdf - 运行命令:
python3 skills/pdf-translator/scripts/extract_text.py papers/deep_learning.pdf - 将提取的文本翻译为中文。
- 将结果保存到。
papers/deep_learning_translated.md - 回复:“我已完成PDF翻译,并将结果保存至。”
papers/deep_learning_translated.md
用户:“帮我阅读这份manual.pdf”
Claude:
- 定位到。
manual.pdf - 运行提取脚本。
- 根据用户意图进行翻译/总结(如果“阅读”意味着理解,那么翻译或总结都是合适的选择)。