数据翻译
- 作者仓库星标 21,713
- 叉子 2,492
- 作者更新于 2026年6月13日 05:00
- 作者仓库 baoyu-skills
- 领域
- 通用
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @JimLiu · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 底层运行要求
- Bun
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: baoyu-translate
description: >- Three-mode translation skill: quick for direct translation, normal for analysis-informed tran…
category: 通用
runtime: Bun
---
# baoyu-translate 输出预览
## PART A: 任务判断
- 适用问题:通用任务拆解、检查和交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“User Input Tools / Script Directory / Preferences (EXTEND.md)”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于通用任务拆解、检查和交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“User Input Tools / Script Directory / Preferences (EXTEND.md)”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“User Input Tools / Script Directory / Preferences (EXTEND.md)”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: baoyu-translate
description: >- Three-mode translation skill: quick for direct translation, normal for analysis-informed tran…
category: 通用
source: JimLiu/baoyu-skills
---
# baoyu-translate
## 什么时候使用
- 中英互译文档时给你三档选择——快译直翻、精校润色、按目标语言习惯重写 适合处理通用任务拆解、检查、交付和复盘,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤…
- 面向通用任务拆解、检查和交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「User Input Tools / Script Directory / Preferences (EXTEND.md)」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "baoyu-translate" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> User Input Tools / Script Directory / Preferences (EXTEND.md)
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Bun | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} 翻译器
三种模式的翻译技能:「快速」模式用于直接翻译,「普通」模式用于分析辅助翻译,「润色」模式用于包含审阅和润色的完整出版质量工作流。
用户输入工具
当此技能提示用户时,请遵循此工具选择规则(优先级顺序):
- 优先使用当前 Agent 运行时提供的内置用户输入工具——例如
AskUserQuestion、request_user_input、clarify、ask_user或任何等效工具。 - 备用方案:如果不存在此类工具,则发出带编号的纯文本消息,并要求用户回复所选的编号/答案以回答每个问题。
- 批量处理:如果工具支持每次调用多个问题,则将所有适用问题合并到一次调用中;如果只支持单个问题,则按优先级顺序逐一提问。
下面具体的 AskUserQuestion 引用是示例——在其他运行时中请替换为本地等效工具。
脚本目录
脚本位于 scripts/ 子目录中。{baseDir} = 此 SKILL.md 的目录路径。解析 ${BUN_X} 运行时:如果安装了 bun → bun;如果 npx 可用 → npx -y bun;否则建议安装 bun。将 {baseDir} 和 ${BUN_X} 替换为实际值。
| 脚本 | 用途 |
|---|---|
scripts/main.ts |
CLI 入口点。默认操作将 Markdown 分割成块;也支持显式 chunk 子命令 |
scripts/chunk.ts |
main.ts 使用的 Markdown 分块实现,并保持兼容以便直接调用 |
首选项 (EXTEND.md)
按优先级顺序检查 EXTEND.md——找到的第一个生效:
| 优先级 | 路径 | 范围 |
|---|---|---|
| 1 | .baoyu-skills/baoyu-translate/EXTEND.md |
项目 |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-translate/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-translate/EXTEND.md |
用户主目录 |
| 结果 | 操作 |
|---|---|
| 找到 | 读取、解析、应用。在会话中首次使用时,简要提醒:「正在使用 [路径] 中的首选项。您可以编辑 EXTEND.md 以自定义词汇表、受众等。」 |
| 未找到 | 必须运行首次设置(见下文)——不要静默使用默认值 |
EXTEND.md 支持:默认目标语言、默认模式、目标受众、自定义词汇表(内联或文件路径)、翻译风格、分块设置。
Schema:references/config/extend-schema.md。
首次设置(阻塞)
关键:当未找到 EXTEND.md 时,在进行任何翻译之前,您必须运行首次设置。这是一个阻塞操作。
完整参考:references/config/first-time-setup.md
使用 AskUserQuestion 在一次调用中提出所有问题(目标语言、模式、受众、风格、保存位置)。用户回答后,在所选位置创建 EXTEND.md,确认「首选项已保存到 [路径]」,然后继续。
默认值
所有可配置值集中于一处。EXTEND.md 覆盖这些默认值;CLI 标志覆盖 EXTEND.md。
| 设置 | 默认值 | EXTEND.md 键 | CLI 标志 | 描述 |
|---|---|---|---|---|
| 目标语言 | zh-CN |
target_language |
--to |
翻译目标语言 |
| 模式 | normal |
default_mode |
--mode |
翻译模式 |
| 受众 | general |
audience |
--audience |
目标读者画像 |
| 风格 | storytelling |
style |
--style |
翻译风格偏好 |
| 分块阈值 | 4000 |
chunk_threshold |
— | 触发分块翻译的字数阈值 |
| 分块最大字数 | 5000 |
chunk_max_words |
— | 每个分块的最大字数 |
模式
| 模式 | 标志 | 步骤 | 何时使用 |
|---|---|---|---|
| 快速 | --mode quick |
翻译 | 短文本、非正式内容、快速任务 |
| 普通 | --mode normal (默认) |
分析 → 翻译 | 文章、博客文章、一般内容 |
| 润色 | --mode refined |
分析 → 翻译 → 审阅 → 润色 | 出版质量、重要文档 |
默认模式:普通(可在 EXTEND.md 的 default_mode 设置中覆盖)。
风格预设——控制翻译的语气和语调(独立于受众):
| 值 | 描述 | 效果 |
|---|---|---|
storytelling |
引人入胜的叙事流(默认) | 吸引读者,过渡流畅,措辞生动 |
formal |
专业、结构化 | 语气中立,组织清晰,无口语化表达 |
technical |
精确、文档风格 | 简洁,术语密集,极少修饰 |
literal |
贴近原文结构 | 极少重构,保留源句式模式 |
academic |
学术、严谨 | 正式语体,可接受复杂从句,注意引用 |
business |
简洁、注重结果 | 行动导向,对高管友好,注重要点 |
humorous |
保留并改编幽默 | 机智、俏皮,在目标语言中重现喜剧效果 |
conversational |
随意、口语化 | 友好、平易近人,如同向朋友解释 |
elegant |
文学、优美散文 | 审美精致,富有韵律,精心选择词语 |
也接受自定义风格描述,例如 --style "poetic and lyrical"。
自动检测:
- 「快翻」、「quick」、「直接翻译」→ 快速模式
- 「精翻」、「refined」、「publication quality」、「proofread」→ 润色模式
- 否则 → 默认模式(普通)
升级提示:普通模式完成后,显示:
翻译已保存。如需进一步审阅和润色,请回复「继续润色」或「refine」。
如果用户响应,则对现有输出继续进行审阅 → 润色步骤(与 refined-workflow.md 中润色模式的步骤 4-6 相同)。
受众预设:
| 值 | 描述 | 效果 |
|---|---|---|
general |
普通读者(默认) | 语言平实,对行话提供更多译者注 |
technical |
开发者/工程师 | 对常见技术术语的注释较少 |
academic |
研究人员/学者 | 正式语体,术语精确 |
business |
商务专业人士 | 商务友好型语调,解释技术概念 |
也接受自定义受众描述,例如 --audience "AI感兴趣的普通读者"。
工作流
步骤 1:加载首选项
1.1 检查 EXTEND.md(参见上面的「首选项」部分)
1.2 如果可用,加载语言对的内置词汇表:
1.3 合并词汇表:EXTEND.md glossary(内联)+ EXTEND.md glossary_files(外部文件,路径相对于 EXTEND.md 位置)+ 内置词汇表 + --glossary 文件(CLI 覆盖所有)
步骤 2:具体化源文件并创建输出目录
具体化源文件(文件保持原样,内联文本/URL → 保存到 translate/{slug}.md),然后创建输出目录:{source-dir}/{source-basename}-{target-lang}/。如果未指定 --from,则检测源语言。
完整详情:references/workflow-mechanics.md
输出目录内容(所有中间文件和最终文件都放在这里):
| 文件 | 模式 | 描述 |
|---|---|---|
translation.md |
所有 | 最终译文(始终为此名称) |
01-analysis.md |
普通、润色 | 内容分析(领域、语调、术语) |
02-prompt.md |
普通、润色 | 组装好的翻译提示词 |
03-draft.md |
润色 | 审阅前的初稿 |
04-critique.md |
润色 | 批判性审阅发现(仅诊断) |
05-revision.md |
润色 | 基于批判性审阅的修订译文 |
chunks/ |
分块 | 源分块 + 翻译分块 |
步骤 3:评估内容长度
快速模式不分块——无论长度如何都直接翻译。翻译前,估算字数。如果内容超过分块阈值(默认 4000 字),主动警告:「本文约 {N} 字。快速模式一次性翻译,不分块——对于长内容,--mode normal 通过术语一致性可产生更好的结果。」如果用户不切换,则继续。
对于普通和润色模式:
| 内容 | 操作 |
|---|---|
| < 分块阈值 | 作为单个单元翻译 |
| >= 分块阈值 | 分块翻译(参见步骤 3.1) |
3.1 长内容准备(普通/润色模式,仅当 >= 分块阈值时)
在翻译分块之前:
- 提取术语:扫描整个文档以查找专有名词、技术术语、重复短语
- 构建会话词汇表:将提取的术语与已加载的词汇表合并,建立一致的翻译
- 分割成块:使用
${BUN_X} {baseDir}/scripts/main.ts <file> [--max-words <chunk_max_words>] [--output-dir <output-dir>]- 解析 Markdown 块(标题、段落、列表、代码块、表格等)
- 在 Markdown 块边界处分割以保留结构
- 如果单个块超过阈值,则回退到按行分割,然后按词分割
- 组装翻译提示词:
- 主 Agent 读取
01-analysis.md(如果存在),并使用 references/subagent-prompt-template.md 的第一部分组装共享上下文——内联:目标风格、内容背景、合并后的词汇表和翻译挑战 - 将其保存为输出目录中的
02-prompt.md(仅共享上下文,无任务指令)
- 主 Agent 读取
- 通过子 Agent 起草翻译(如果 Agent 工具可用):
- 每个分块生成一个子 Agent,全部并行(模板的第二部分)
- 每个子 Agent 读取
02-prompt.md获取共享上下文,接收分块位置信息(M 个分块中的第 N 个分块 + 其在论证中的简要上下文),翻译其分块,保存到chunks/chunk-NN-draft.md - 一致性由共享的
02-prompt.md保证(词汇表、比喻语言映射、理解挑战、源语调以及分析中的翻译挑战) - 如果没有分块(内容低于阈值):为整个源文件生成一个子 Agent
- 如果 Agent 工具不可用,则使用
02-prompt.md顺序内联翻译分块
- 合并:所有子 Agent 完成后,按顺序合并翻译后的分块。如果存在
chunks/frontmatter.md,则将其前置。保存为03-draft.md(润色模式)或translation.md(普通模式) - 所有中间文件(源分块 + 翻译分块)都保留在
chunks/中
分块草稿合并后,将控制权返回给主 Agent 进行批判性审阅、修订和润色(步骤 4)。
步骤 4:翻译与润色
翻译原则(适用于所有模式):
- 重写而非翻译:将内容重写为自然、引人入胜的目标语言,仿佛一位熟练的母语作家从头创作。质量测试:「这读起来是否像是最初用目标语言写成的?」
- 准确性优先:事实、数据和逻辑必须与原文完全一致
- 自然流畅:使用地道的目标语言词序。将长源句分解成更短、更自然的句子。按预期含义而非逐字解释隐喻和习语
- 术语:始终使用标准翻译。专业术语首次出现时:用括号标注原文
- 保留格式:保留所有 Markdown 格式(标题、粗体、斜体、图片、链接、代码块)
- 主动解释:对于目标受众可能缺乏上下文的行话或概念,在粗体括号
(**解释**)中添加简洁的解释。注释要少——仅在真正需要理解时才添加 - Frontmatter:如果源文件有 YAML frontmatter,将源元数据字段重命名为
source前缀(驼峰命名法:url→sourceUrl,title→sourceTitle等),将翻译后的值添加为新的顶级字段(如果正文有 H1 则跳过title),其他字段保持不变
快速模式
直接翻译 → 保存到 translation.md。应用上述所有翻译原则。
普通模式
- 分析 →
01-analysis.md(领域、语调、术语、翻译挑战) - 组装提示词 →
02-prompt.md(包含上下文、词汇表、挑战的翻译指令) - 翻译(遵循
02-prompt.md)→translation.md
完成后,提示用户:「翻译已保存。如需进一步审阅和润色,请回复继续润色或refine。」
如果用户继续,则进行批判性审阅 → 修订 → 润色(与下面润色模式的步骤 4-6 相同),保存 03-draft.md(重命名当前的 translation.md)、04-critique.md、05-revision.md 和更新后的 translation.md。
润色模式
出版质量的完整工作流。有关每个步骤的详细指南,请参阅 references/refined-workflow.md。
子 Agent(如果在步骤 3.1 中使用)仅处理初稿。所有后续步骤(批判性审阅、修订、润色)均由主 Agent 处理,主 Agent 可酌情委托给子 Agent。
步骤和保存的文件(全部在输出目录中):
- 分析 →
01-analysis.md(领域、语调、术语、翻译挑战) - 组装提示词 →
02-prompt.md(包含内联上下文的翻译指令) - 起草 →
03-draft.md(包含译者注的初稿;如果分块则来自子 Agent) - 批判性审阅 →
04-critique.md(仅诊断:准确性、欧化语言、策略执行、表达问题) - 修订 →
05-revision.md(应用所有批判性审阅发现以生成修订译文) - 润色 →
translation.md(最终出版质量译文)
每个步骤都读取上一步的文件并在此基础上进行。
步骤 5:输出
最终译文始终位于输出目录中的 translation.md。
最终译文写入后,进行轻量级图像语言检查:
- 从翻译后的文章中收集图像引用
- 识别可能包含大量文本的图像,例如封面、截图、图表、框架图和信息图
- 如果任何图像可能包含与翻译文章语言不符的主要文本语言,则主动提醒用户
- 提醒必须仅为列表。除非用户要求,否则不要自动本地化这些图像
提醒格式(使用文章中已有的任何图像语法——标准 Markdown 或 Wikilink):
可能需要图像本地化:
- :文章现为目标语言,但图像可能仍包含源语言文本
- :可能是文本密集的框架图,检查标签是否需要翻译
显示摘要:
**翻译完成**({mode} 模式)
源文件:{source-path}
语言:{from} → {to}
输出目录:{output-dir}/
最终文件:{output-dir}/translation.md
已应用词汇表术语:{count}
如果发现图像语言不匹配的候选,在摘要后附加一条简短说明,告知用户某些嵌入图像可能仍需要图像文本本地化,然后列出候选列表。
扩展支持
通过 EXTEND.md 进行自定义配置。有关路径和支持选项,请参阅「首选项」部分。
Translator
Three-mode translation skill: quick for direct translation, normal for analysis-informed translation, refined for full publication-quality workflow with review and polish.
User Input Tools
When this skill prompts the user, follow this tool-selection rule (priority order):
- Prefer built-in user-input tools exposed by the current agent runtime — e.g.,
AskUserQuestion,request_user_input,clarify,ask_user, or any equivalent. - Fallback: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question.
- Batching: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.
Concrete AskUserQuestion references below are examples — substitute the local equivalent in other runtimes.
Script Directory
Scripts in scripts/ subdirectory. {baseDir} = this SKILL.md's directory path. Resolve ${BUN_X} runtime: if bun installed → bun; if npx available → npx -y bun; else suggest installing bun. Replace {baseDir} and ${BUN_X} with actual values.
| Script | Purpose |
|---|---|
scripts/main.ts |
CLI entry point. Default action splits markdown into chunks; also supports explicit chunk subcommand |
scripts/chunk.ts |
Markdown chunking implementation used by main.ts and kept compatible for direct invocation |
Preferences (EXTEND.md)
Check EXTEND.md in priority order — the first one found wins:
| Priority | Path | Scope |
|---|---|---|
| 1 | .baoyu-skills/baoyu-translate/EXTEND.md |
Project |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-translate/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-translate/EXTEND.md |
User home |
| Result | Action |
|---|---|
| Found | Read, parse, apply. On first use in session, briefly remind: "Using preferences from [path]. You can edit EXTEND.md to customize glossary, audience, etc." |
| Not found | MUST run first-time setup (see below) — do NOT silently use defaults |
EXTEND.md supports: default target language, default mode, target audience, custom glossaries (inline or file path), translation style, chunk settings.
Schema: references/config/extend-schema.md.
First-Time Setup (BLOCKING)
CRITICAL: When EXTEND.md is not found, you MUST run the first-time setup before ANY translation. This is a BLOCKING operation.
Full reference: references/config/first-time-setup.md
Use AskUserQuestion with all questions (target language, mode, audience, style, save location) in ONE call. After user answers, create EXTEND.md at the chosen location, confirm "Preferences saved to [path]", then continue.
Defaults
All configurable values in one place. EXTEND.md overrides these; CLI flags override EXTEND.md.
| Setting | Default | EXTEND.md key | CLI flag | Description |
|---|---|---|---|---|
| Target language | zh-CN |
target_language |
--to |
Translation target language |
| Mode | normal |
default_mode |
--mode |
Translation mode |
| Audience | general |
audience |
--audience |
Target reader profile |
| Style | storytelling |
style |
--style |
Translation style preference |
| Chunk threshold | 4000 |
chunk_threshold |
— | Word count to trigger chunked translation |
| Chunk max words | 5000 |
chunk_max_words |
— | Max words per chunk |
Modes
| Mode | Flag | Steps | When to Use |
|---|---|---|---|
| Quick | --mode quick |
Translate | Short texts, informal content, quick tasks |
| Normal | --mode normal (default) |
Analyze → Translate | Articles, blog posts, general content |
| Refined | --mode refined |
Analyze → Translate → Review → Polish | Publication-quality, important documents |
Default mode: Normal (can be overridden in EXTEND.md default_mode setting).
Style presets — control the voice and tone of the translation (independent of audience):
| Value | Description | Effect |
|---|---|---|
storytelling |
Engaging narrative flow (default) | Draws readers in, smooth transitions, vivid phrasing |
formal |
Professional, structured | Neutral tone, clear organization, no colloquialisms |
technical |
Precise, documentation-style | Concise, terminology-heavy, minimal embellishment |
literal |
Close to original structure | Minimal restructuring, preserves source sentence patterns |
academic |
Scholarly, rigorous | Formal register, complex clauses OK, citation-aware |
business |
Concise, results-focused | Action-oriented, executive-friendly, bullet-point mindset |
humorous |
Preserves and adapts humor | Witty, playful, recreates comedic effect in target language |
conversational |
Casual, spoken-like | Friendly, approachable, as if explaining to a friend |
elegant |
Literary, polished prose | Aesthetically refined, rhythmic, carefully crafted word choices |
Custom style descriptions are also accepted, e.g., --style "poetic and lyrical".
Auto-detection:
- "快翻", "quick", "直接翻译" → quick mode
- "精翻", "refined", "publication quality", "proofread" → refined mode
- Otherwise → default mode (normal)
Upgrade prompt: After normal mode completes, display:
Translation saved. To further review and polish, reply "继续润色" or "refine".
If user responds, continue with review → polish steps (same as refined mode Steps 4-6 in refined-workflow.md) on the existing output.
Audience presets:
| Value | Description | Effect |
|---|---|---|
general |
General readers (default) | Plain language, more translator's notes for jargon |
technical |
Developers / engineers | Less annotation on common tech terms |
academic |
Researchers / scholars | Formal register, precise terminology |
business |
Business professionals | Business-friendly tone, explain tech concepts |
Custom audience descriptions are also accepted, e.g., --audience "AI感兴趣的普通读者".
Workflow
Step 1: Load Preferences
1.1 Check EXTEND.md (see Preferences section above)
1.2 Load built-in glossary for the language pair if available:
- EN→ZH: references/glossary-en-zh.md
1.3 Merge glossaries: EXTEND.md glossary (inline) + EXTEND.md glossary_files (external files, paths relative to EXTEND.md location) + built-in glossary + --glossary file (CLI overrides all)
Step 2: Materialize Source & Create Output Directory
Materialize source (file as-is, inline text/URL → save to translate/{slug}.md), then create output directory: {source-dir}/{source-basename}-{target-lang}/. Detect source language if --from not specified.
Full details: references/workflow-mechanics.md
Output directory contents (all intermediate and final files go here):
| File | Mode | Description |
|---|---|---|
translation.md |
All | Final translation (always this name) |
01-analysis.md |
Normal, Refined | Content analysis (domain, tone, terminology) |
02-prompt.md |
Normal, Refined | Assembled translation prompt |
03-draft.md |
Refined | Initial draft before review |
04-critique.md |
Refined | Critical review findings (diagnosis only) |
05-revision.md |
Refined | Revised translation based on critique |
chunks/ |
Chunked | Source chunks + translated chunks |
Step 3: Assess Content Length
Quick mode does not chunk — translate directly regardless of length. Before translating, estimate word count. If content exceeds chunk threshold (default 4000 words), proactively warn: "This article is ~{N} words. Quick mode translates in one pass without chunking — for long content, --mode normal produces better results with terminology consistency." Then proceed if user doesn't switch.
For normal and refined modes:
| Content | Action |
|---|---|
| < chunk threshold | Translate as single unit |
| >= chunk threshold | Chunk translation (see Step 3.1) |
3.1 Long Content Preparation (normal/refined modes, >= chunk threshold only)
Before translating chunks:
- Extract terminology: Scan entire document for proper nouns, technical terms, recurring phrases
- Build session glossary: Merge extracted terms with loaded glossaries, establish consistent translations
- Split into chunks: Use
${BUN_X} {baseDir}/scripts/main.ts <file> [--max-words <chunk_max_words>] [--output-dir <output-dir>]- Parses markdown blocks (headings, paragraphs, lists, code blocks, tables, etc.)
- Splits at markdown block boundaries to preserve structure
- If a single block exceeds the threshold, falls back to line splitting, then word splitting
- Assemble translation prompt:
- Main agent reads
01-analysis.md(if exists) and assembles shared context using Part 1 of references/subagent-prompt-template.md — inlining: target style, content background, merged glossary, and translation challenges - Save as
02-prompt.mdin the output directory (shared context only, no task instructions)
- Main agent reads
- Draft translation via subagents (if Agent tool available):
- Spawn one subagent per chunk, all in parallel (Part 2 of the template)
- Each subagent reads
02-prompt.mdfor shared context, receives chunk position info (chunk N of M + brief context of where it sits in the argument), translates its chunk, saves tochunks/chunk-NN-draft.md - Consistency is guaranteed by the shared
02-prompt.md(glossary, figurative language mapping, comprehension challenges, source voice, and translation challenges from analysis) - If no chunks (content under threshold): spawn one subagent for the entire source file
- If Agent tool is unavailable, translate chunks sequentially inline using
02-prompt.md
- Merge: Once all subagents complete, combine translated chunks in order. If
chunks/frontmatter.mdexists, prepend it. Save as03-draft.md(refined) ortranslation.md(normal) - All intermediate files (source chunks + translated chunks) are preserved in
chunks/
After chunked draft is merged, return control to main agent for critical review, revision, and polish (Step 4).
Step 4: Translate & Refine
Translation principles (apply to all modes):
- Rewrite, not translate: Rewrite content into natural, engaging target language as if a skilled native writer composed it from scratch. Quality test: "Does this read like it was originally written in the target language?"
- Accuracy first: Facts, data, and logic must match the original exactly
- Natural flow: Use idiomatic target language word order. Break long source sentences into shorter, natural ones. Interpret metaphors and idioms by intended meaning, not word-for-word
- Terminology: Use standard translations consistently. First occurrence of specialized terms: annotate with original in parentheses
- Preserve format: Keep all markdown formatting (headings, bold, italic, images, links, code blocks)
- Proactive interpretation: For jargon or concepts the target audience may lack context for, add concise explanations in bold parentheses
(**解释**). Keep annotations few — only where genuinely needed for comprehension - Frontmatter: If source has YAML frontmatter, rename source-metadata fields with
sourceprefix (camelCase:url→sourceUrl,title→sourceTitle, etc.), add translated values as new top-level fields (skiptitleif body has H1), keep other fields as-is
Quick Mode
Translate directly → save to translation.md. Apply all translation principles above.
Normal Mode
- Analyze →
01-analysis.md(domain, tone, terminology, translation challenges) - Assemble prompt →
02-prompt.md(translation instructions with context, glossary, challenges) - Translate (following
02-prompt.md) →translation.md
After completion, prompt user: "Translation saved. To further review and polish, reply 继续润色 or refine."
If user continues, proceed with critical review → revision → polish (same as refined mode Steps 4-6 below), saving 03-draft.md (rename current translation.md), 04-critique.md, 05-revision.md, and updated translation.md.
Refined Mode
Full workflow for publication quality. See references/refined-workflow.md for detailed guidelines per step.
The subagent (if used in Step 3.1) only handles the initial draft. All subsequent steps (critical review, revision, polish) are handled by the main agent, which may delegate to subagents at its discretion.
Steps and saved files (all in output directory):
- Analyze →
01-analysis.md(domain, tone, terminology, translation challenges) - Assemble prompt →
02-prompt.md(translation instructions with inlined context) - Draft →
03-draft.md(initial translation with translator's notes; from subagent if chunked) - Critical review →
04-critique.md(diagnosis only: accuracy, Europeanized language, strategy execution, expression issues) - Revision →
05-revision.md(apply all critique findings to produce revised translation) - Polish →
translation.md(final publication-quality translation)
Each step reads the previous step's file and builds on it.
Step 5: Output
Final translation is always at translation.md in the output directory.
After the final translation is written, do a lightweight image-language pass:
- Collect image references from the translated article
- Identify likely text-heavy images such as covers, screenshots, diagrams, charts, frameworks, and infographics
- If any image likely contains a main text language that does not match the translated article language, proactively remind the user
- The reminder must be a list only. Do not automatically localize those images unless the user asks
Reminder format (use whatever image syntax the article already uses — standard markdown or wikilink):
Possible image localization needed:
- : likely still contains source-language text while the article is now in target language
- : likely text-heavy framework graphic, check whether labels need translation
Display summary:
**Translation complete** ({mode} mode)
Source: {source-path}
Languages: {from} → {to}
Output dir: {output-dir}/
Final: {output-dir}/translation.md
Glossary terms applied: {count}
If mismatched image-language candidates were found, append a short note after the summary telling the user that some embedded images may still need image-text localization, followed by the candidate list.
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核