translate

A command for translating English text, Markdown files, or directories of Markdown files into natural Chinese while preserving the document structure.

In plain words
What is it for?
Use it for direct text translation, single Markdown files, or batches of Markdown files; it can also create backups before translating files.
Why use it?
It removes the need to translate documents one by one and helps keep Markdown formatting, technical terms, and the original meaning intact.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/ysicing/code-pilot/translate
Clone the repo
git clone --depth 1 https://github.com/ysicing/code-pilot
Per session 28 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,688 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00028 $0.03688
Opus 5 $0.00014 $0.01844
Sonnet 5 $0.00006 $0.00738
Haiku 4.5 $0.00003 $0.00369

Measured yesterday against content hash 2816bb1f3e77, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

translate scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/translate.md · 405 lines

How it starts

The opening of the file, as written. The whole thing — 405 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Translate - 智能中文翻译工具

专业的英文到中文翻译命令,支持直接文本翻译、单文件翻译和目录批量翻译。提供高质量的翻译结果,语句通顺无歧义,标点符号使用正确,在不改变原文基础上进行润色修饰。

用法:

# 直接文本翻译
/translate "Your English text here"

# 单Markdown文件翻译
/translate /path/to/file.md

# 目录批量翻译(仅处理 .md 文件)
/translate /path/to/directory/

# 无参数时进入交互模式
/translate

核心特性:

多模式翻译支持

  • 直接文本翻译:即时翻译输入的英文文本
  • Markdown 文件翻译:翻译指定 Markdown 文件内容并保存结果
  • 目录批量翻译:批量处理目录下的所有 Markdown 文件
  • 交互模式:无参数时提供用户选择界面

智能文件处理

  • 文件类型识别:专注处理 Markdown 文件(.md, .markdown, .mdown)
  • 格式保持:完整保留原文件的 Markdown 格式结构
  • 安全备份:翻译前自动创建文件备份
  • 批量处理:支持目录下 Markdown 文件并行翻译

翻译质量标准

  • 语句通顺:确保翻译后的中文语法正确,表达自然
  • 无歧义性:避免模糊表达,确保意思明确
  • 标点规范:使用标准中文标点符号
  • 适度润色:在保持原意基础上优化表达方式

专业术语处理

  • 技术名词:保留英文原文(如 API、JWT、React)
  • 专业术语:保持专业性和准确性
  • 影视剧台词:保留原文特色,不进行翻译
  • 品牌名称:保持原有英文名称

智能处理规则

  • 上下文分析:根据语境选择最合适的翻译
  • 语言风格:保持与原文相符的语言风格
  • 文档格式:保留 Markdown、代码块等格式结构
  • 术语一致性:确保同一文档中术语翻译的一致性

处理流程:

1. 参数分析阶段

  • 无参数检测:判断是否需要进入交互模式
  • 路径验证:检查输入是文件路径、目录路径还是文本内容
  • 文件类型识别:分析文件扩展名和内容类型
  • 权限验证:确认文件读写权限

2. 交互模式处理(无参数时)

  • 显示选择菜单
    请选择翻译模式:
    1. 直接输入文本翻译
    2. 翻译指定文件
    3. 翻译目录下所有文件
    4. 退出
    
  • 获取用户选择:等待用户输入选项
  • 参数收集:根据选择收集必要的路径或文本信息
  • 确认执行:显示操作预览,等待用户确认

3. 文件/目录处理阶段

  • 单文件模式

    • 读取文件内容
    • 创建 .backup 备份文件
    • 执行翻译处理
    • 保存翻译结果(可选择覆盖原文件或新建文件)
  • 目录批量模式

    • 扫描目录下的 Markdown 文件(.md, .markdown, .mdown)
    • 显示文件列表供用户确认
    • 批量处理每个文件
    • 生成处理报告

4. 文本翻译阶段

  • 识别文本类型(技术文档、普通文本、代码注释等)
  • 提取专业术语和技术名词
  • 分析语言风格和表达特点
  • 确定翻译策略和重点

5. 翻译处理阶段

  • 按句子为单位进行精确翻译
  • 保留技术术语的英文原文
  • 调整语序符合中文表达习惯
  • 确保专业概念的准确传达

6. 润色优化阶段

  • 检查语句通顺性和逻辑连贯性
  • 优化表达方式,提升可读性
  • 统一术语翻译,确保一致性
  • 最终质量检查和校对

使用示例:

交互模式示例

/translate
# 输出:
# 请选择翻译模式:
# 1. 直接输入文本翻译
# 2. 翻译指定文件  
# 3. 翻译目录下所有文件
# 4. 退出
# 请输入选择 (1-4): 

直接文本翻译

/translate "This function validates user authentication tokens"
# 输出:此函数验证用户身份验证 token

单文件翻译

/translate ./docs/README.md
# 输出:
# 📄 翻译文件: ./docs/README.md
# 💾 备份文件: ./docs/README.md.backup
# ✅ 翻译完成,结果保存至: ./docs/README_zh.md

Read the full file on GitHub · 405 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 405 lines · 28 tokens per session scan A 2816bb1f3e77

Subscribe to this mod's changes

translate is a command published in the GitHub repository ysicing/code-pilot (38 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 28 tokens to every session and 3,688 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.