把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。
文档
Universal Translator
试用把 Word、PDF、Excel、PowerPoint、HTML、Markdown 与 TXT 文档翻译成另一种语言,同时保留原始排版。
它能做什么
提供七种文档格式(DOCX、XLSX、PPTX、PDF、HTML、MD、TXT)的 Python 解析与回写框架。智能体需要通过 translator_fn 参数接入自己的 LLM 翻译函数,框架按段落、单元格、形状或章节逐段调用该函数,并把译文写回同一文档结构,从而保留排版与样式。附带 translate_folder 方法,可一次性处理整个目录中的混合文件。代码中默认的 _translate_text 仅为占位实现,仅用于测试解析流程,上线前必须替换为真实 LLM 调用。文档内容会发送到智能体环境所配置的 LLM(本地或远端,取决于部署设置)。
什么时候用它
- 翻译 Word 报告并保留标题、表格与样式
- 一次性批量翻译整个文件夹里所有受支持的文档
- 翻译 PPT 幻灯片或 HTML 页面,按幻灯片与形状逐个替换文本
- 把一个混合了 DOCX、XLSX、PPTX、MD、TXT 的目录统一翻译为目标语言
技能文档
Universal Translator
Translate any document format while preserving layout and formatting.
Features
- 📄 All Formats: Word, PDF, Excel, PPT, HTML, Markdown, TXT
- 📁 Batch Translation: Translate entire folders
- 🎯 Terminology: Keep terms consistent
- 🌍 50+ Languages: Chinese, English, Japanese, etc.
- 📐 Format Preserved: Keep original layout
Supported Formats
| Format | Extension | Method |
|---|---|---|
| Word | .docx | python-docx |
| Excel | .xlsx | openpyxl |
| PowerPoint | .pptx | python-pptx |
| pymupdf | ||
| HTML | .html | BeautifulSoup |
| Markdown | .md | text processing |
| Text | .txt | text processing |
Note: Only modern formats are supported. For .xls files, convert to .xlsx first.
Trigger Conditions
Only when the user asks to translate a document file (Word/PDF/Excel/PPT/HTML/MD/TXT) to another language.
How Translation Works
⚠️ 数据外发提醒:文档内容由 AI 读取并逐段发送至配置中的 LLM 进行翻译。LLM 的运行位置(本地/远程)取决于 OpenClaw 配置。
This is a Framework Skill: it provides document parsing boilerplate (read Word/Excel/PPT/PDF files, iterate paragraphs/cells/shapes, write output). The AI agent's own LLM performs the actual translation.
Translation workflow:
- Use the Python code below to open the document and extract text
- For each paragraph/cell/shape, translate the text using your LLM
- Write the translated text back into the document
- Save the output file
Note: The _translate_text method is a stub — you MUST replace it with actual LLM translation. The stub exists only to let you test the parsing flow; do not use it in production.
Python Code
import os
from pathlib import Path
from docx import Document
import openpyxl
from pptx import Presentation
class UniversalTranslator:
def __init__(self):
self.supported = {
'word': ['.docx'],
'excel': ['.xlsx', '.xls'],
'powerpoint': ['.pptx'],
'pdf': ['.pdf'],
'html': ['.html', '.htm'],
'markdown': ['.md'],
'text': ['.txt']
}
def detect_format(self, file_path):
"""Detect file format"""
ext = Path(file_path).suffix.lower()
for format_type, extensions in self.supported.items():
if ext in extensions:
return format_type
return 'unknown'
def translate_word(self, input_path, output_path, translator_fn):
"""Translate Word document.
Args:
translator_fn: callable(text, target_lang) -> translated_text
Agent should pass its LLM translate function here.
"""
doc = Document(input_path)
for para in doc.paragraphs:
if para.text.strip():
translated = translator_fn(para.text, 'en')
para.clear()
para.add_run(translated)
for table in doc.tables:
for row in table.rows:
for cell in row.cells:
if cell.text.strip():
translated = translator_fn(cell.text, 'en')
cell.text = translated
doc.save(output_path)
return output_path
def translate_excel(self, input_path, output_path, translator_fn):
"""Translate Excel file."""
wb = openpyxl.load_workbook(input_path)
for sheet in wb.worksheets:
for row in sheet.iter_rows():
for cell in row:
if cell.value and isinstance(cell.value, str):
translated = translator_fn(cell.value, 'en')
cell.value = translated
wb.save(output_path)
return output_path
def translate_pptx(self, input_path, output_path, translator_fn):
"""Translate PowerPoint."""
prs = Presentation(input_path)
for slide in prs.slides:
for shape in slide.shapes:
if hasattr(shape, 'text') and shape.text.strip():
translated = translator_fn(shape.text, 'en')
shape.text = translated
prs.save(output_path)
return output_path
def translate_markdown(self, input_path, output_path, translator_fn):
"""Translate Markdown file."""
with open(input_path, 'r', encoding='utf-8') as f:
content = f.read()
sections = content.split('\n\n')
translated_sections = []
for section in sections:
if section.strip():
translated = translator_fn(section, 'en')
translated_sections.append(translated)
else:
translated_sections.append('')
translated_content = '\n\n'.join(translated_sections)
with open(output_path, 'w', encoding='utf-8') as f:
f.write(translated_content)
return output_path
def translate_folder(self, folder_path, output_folder, target_lang, translator_fn):
"""Translate all files in folder."""
os.makedirs(output_folder, exist_ok=True)
results = []
for file_path in Path(folder_path).rglob('*'):
if file_path.is_file():
format_type = self.detect_format(str(file_path))
if format_type != 'unknown':
output_path = os.path.join(output_folder, file_path.name)
try:
if format_type == 'word':
self.translate_word(str(file_path), output_path, translator_fn)
elif format_type == 'excel':
self.translate_excel(str(file_path), output_path, translator_fn)
elif format_type == 'powerpoint':
self.translate_pptx(str(file_path), output_path, translator_fn)
elif format_type in ['markdown', 'text']:
self.translate_markdown(str(file_path), output_path, translator_fn)
results.append({'file': file_path.name, 'status': 'success'})
except Exception as e:
results.append({'file': file_path.name, 'status': 'error', 'error': str(e)})
return results
## Usage Examples
User: "Translate this Word document to English" Agent:
- pip install python-docx (if not installed)
- Use translator.translate_word() to parse .docx
- For each paragraph, call your LLM to translate
- Write translated text back, save output
User: "Translate all files in this folder to Chinese" Agent:
- Ensure required libs are installed
- Use translator.translate_folder() for parsing
- Translate text via your LLM
- Save all translated files
User: "翻译这份PDF成日文" Agent:
- Extract text from PDF
- Translate using your LLM
- Save as new document
## Notes
- Supports Word (.docx), Excel (.xlsx), PPT (.pptx), PDF, HTML, Markdown, TXT
- The parsing code preserves original formatting — the AI agent only replaces text content
- Install dependencies: `pip install python-docx openpyxl python-pptx`
- For PDF support: `pip install pymupdf`
- For HTML: `pip install beautifulsoup4`
相关技能
以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。
在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。
诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。
从 AdMapix API 拉取广告创意、应用、榜单和收入预估等数据,原样返回结构化 JSON。
编写、调试与调优 Playwright 测试,涵盖定位器策略、追踪诊断与 CI 友好的超时配置。
tobewin 的更多技能
浏览全部技能用一份 JSON 描述就能生成标准可编辑的 PPTX,自带 11 种版式与 5 套配色。
Professional Excel spreadsheet generator. Use when user needs to create data tables, reports, charts, financial models, or any structured data in Excel forma...
中国新闻资讯聚合工具。Use when user wants to get latest news from Chinese sources. Supports multiple news sites (Sina, Sohu, NetEase, Tencent) via browser automation an...
Data analysis tool for Excel, CSV, Word, PDF, TXT, Markdown files. Use when user needs to analyze, summarize, or compare data from multiple files. Supports f...
Marketing plan generator with web research and Word output. Use when user needs to create marketing plans, promotional campaigns, social media strategies. Fe...
Data visualization chart generator. Use when user needs to create charts from data for reports, presentations, or documents. Supports bar, line, pie, scatter...