pdf-translator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PDF Translator Skill

PDF Translator Skill

Instructions

说明

Follow these steps to translate a PDF file:
  1. 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.
  2. Extract Text: Use the
    extract_text.py
    script located in the
    scripts
    directory of this skill to extract text from the PDF.
    • Command:
      python3 skills/pdf-translator/scripts/extract_text.py <path_to_pdf>
    • Note: Ensure you are using the correct python environment (e.g.,
      .venv/bin/python
      if applicable, or just
      python3
      if dependencies are installed globally).
  3. 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.
  4. 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文件:
  1. 确定PDF文件:确认用户想要翻译的PDF文件路径。如果是相对路径,请将其解析为绝对路径。
  2. 提取文本:使用本技能
    scripts
    目录下的
    extract_text.py
    脚本从PDF中提取文本。
    • 命令:
      python3 skills/pdf-translator/scripts/extract_text.py <path_to_pdf>
    • 注意:确保使用正确的Python环境(例如,适用的话使用
      .venv/bin/python
      ,如果依赖已全局安装则直接使用
      python3
      )。
  3. 翻译内容
    • 读取提取步骤的输出内容。
    • 将提取的文本翻译为用户要求的目标语言(如果不明确,则默认使用用户的主要语言或英语)。
    • 尽可能使用Markdown格式保留原文结构(标题、段落)。
  4. 保存输出
    • 创建一个包含翻译内容的新Markdown文件。
    • 文件名格式:
      <original_filename>_translated.md
    • 通知用户输出文件的位置。

Examples

示例

User: "Translate the file papers/deep_learning.pdf to Chinese."
Claude:
  1. Locates
    papers/deep_learning.pdf
    .
  2. Runs:
    python3 skills/pdf-translator/scripts/extract_text.py papers/deep_learning.pdf
  3. Translates the extracted text to Chinese.
  4. Saves the result to
    papers/deep_learning_translated.md
    .
  5. Responds: "I have translated the PDF and saved it to
    papers/deep_learning_translated.md
    ."
User: "Help me read this manual.pdf"
Claude:
  1. Locates
    manual.pdf
    .
  2. Runs extraction script.
  3. Translates/Summarizes based on user intent (if "read" implies understanding, a translation or summary might be appropriate).
用户:“将文件papers/deep_learning.pdf翻译为中文。”
Claude
  1. 定位到
    papers/deep_learning.pdf
  2. 运行命令:
    python3 skills/pdf-translator/scripts/extract_text.py papers/deep_learning.pdf
  3. 将提取的文本翻译为中文。
  4. 将结果保存到
    papers/deep_learning_translated.md
  5. 回复:“我已完成PDF翻译,并将结果保存至
    papers/deep_learning_translated.md
    。”
用户:“帮我阅读这份manual.pdf”
Claude
  1. 定位到
    manual.pdf
  2. 运行提取脚本。
  3. 根据用户意图进行翻译/总结(如果“阅读”意味着理解,那么翻译或总结都是合适的选择)。