SuperAPI AI Directory

markdown-segment-translator

Writing & research

View repository

Updated 10-16 08:52

About this skill

Markdown segmented translation skill

⚠️ Mandatory requirements - 3-step translation process ⚠️

When the user asks you to translate a markdown file, youmust strictly follow the following 3 stepsto complete it, do not skip any step!


📋 Step 1: Document segmentation

Tool: Bash
Command format:

python3 workspace/skills/markdown-segment-translator/scripts/segment_tool.py segment --input [输入文件] --segment-size 1000 --max-segments 3

Purpose:

  • Split a large document into multiple small segments
  • Segment files are saved in output/segments/segment_1.md, segment_2.md...
  • Metadata is saved in output/metadata/segments_info.json

Example:

python3 workspace/skills/markdown-segment-translator/scripts/segment_tool.py segment --input workspace/2407.14333v5.md --segment-size 1000 --max-segments 3

📋 Step 2: Translate each segment

Tool: Read + Your own LLM capability + Write

Important: You must translate by yourself, do not call any external API!

Process:

For each segment file:

  1. Read the segment: Use Read to read output/segments/segment_1.md
  2. Translate by yourself: Use your own language ability to translate the content from English to Chinese
  3. Save the translation: Use Write to save to output/translations/translated_segment_1.md
  4. Repeat: Process segment_2.md, segment_3.md...

Translation requirements:

  • Keep all Markdown formatting (headings, lists, code blocks, tables, etc.)
  • Accurately translate academic terminology
  • Maintain professionalism and fluency
  • Do not translate code, formulas, URLs
  • Keep the paragraph structure

Translation prompt template:

请将以下Markdown内容从英文翻译为中文:
- 保持所有Markdown格式标记
- 准确翻译学术术语
- 不要翻译代码块、数学公式、URL链接
- 保持专业性

[段落内容]

📋 Step 3: Merge the translation results

Tool: Bash
Command:

python3 workspace/skills/markdown-segment-translator/scripts/segment_tool.py merge

Purpose:

  • Merge all translated segments into a complete file
  • The final file is located at: output/final/complete_translated_[原文件名].md

✅ Complete example

用户请求: 请翻译2407.14333v5.md文件

你的执行步骤:

【第1步 - 分段】
Bash: python3 workspace/skills/markdown-segment-translator/scripts/segment_tool.py segment --input workspace/2407.14333v5.md --segment-size 1000 --max-segments 3

输出: 创建 segment_1.md (1000行), segment_2.md (1000行), segment_3.md (700行)

【第2步 - 翻译】
循环处理每个段落:

Segment 1:
  Read: output/segments/segment_1.md
  [你自己翻译这段内容为中文]
  Write: output/translations/translated_segment_1.md (写入你的翻译)

Segment 2:
  Read: output/segments/segment_2.md
  [你自己翻译这段内容为中文]
  Write: output/translations/translated_segment_2.md

Segment 3:
  Read: output/segments/segment_3.md
  [你自己翻译这段内容为中文]
  Write: output/translations/translated_segment_3.md

【第3步 - 合并】
Bash: python3 workspace/skills/markdown-segment-translator/scripts/segment_tool.py merge

输出: output/final/complete_translated_2407.14333v5.md

【完成】
使用 Read 读取最终文件并向用户报告

❌ Strictly prohibited operations

  • ❌ Do not use the old segment_translator.py script (that one calls the API by itself)
  • ❌ Do not let a Python script call a translation API
  • ❌ Do not skip the segmentation or merging steps
  • ❌ Do not try to translate the entire document all at once
  • ❌ Do not use Bash in Step 2 to call an external translation program

✅ Correct tool call sequence

第1步: Bash (分段工具)
第2步: Read → [你自己翻译] → Write (循环N次)
第3步: Bash (合并工具)
第4步: Read (读取最终结果)

🎯 Why design it this way?

  1. Segmentation: Avoid token limits and ensure complete translation
  2. Agent translation: Leverage your LLM capability without additional API calls
  3. Segment-by-segment processing: Ensure quality and accuracy
  4. Merging: Generate a complete and unified translated document

Skill function overview

This skill specifically solves the token limit problem in long document translation, ensuring 100% complete translation through intelligent segmentation and the Agent's autonomous translation mechanism.

Core advantages:

  • 🔧 Purely tool-based segmentation/merging
  • 🧠 Agent-led translation
  • 📊 Completeness guarantee
  • 🎨 Format preservation
  • 📝 Terminology consistency