Translator
Three-mode translation skill: quick for direct translation, normal for analysis-informed translation, refined for full publication-quality workflow with review and polish.
Script Directory
Scripts in
subdirectory.
= this SKILL.md's directory path. Resolve
runtime: if
installed →
; if
available →
; else suggest installing bun. Replace
and
with actual values.
| Script | Purpose |
|---|
| CLI entry point. Default action splits markdown into chunks; also supports explicit subcommand |
| Markdown chunking implementation used by and kept compatible for direct invocation |
Preferences (EXTEND.md)
Check EXTEND.md existence (priority order):
bash
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-translate/EXTEND.md && echo "project"
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-translate/EXTEND.md" && echo "xdg"
test -f "$HOME/.baoyu-skills/baoyu-translate/EXTEND.md" && echo "user"
powershell
# PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-translate/EXTEND.md) { "project" }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
if (Test-Path "$xdg/baoyu-skills/baoyu-translate/EXTEND.md") { "xdg" }
if (Test-Path "$HOME/.baoyu-skills/baoyu-translate/EXTEND.md") { "user" }
| Path | Location |
|---|
.baoyu-skills/baoyu-translate/EXTEND.md
| Project directory |
$HOME/.baoyu-skills/baoyu-translate/EXTEND.md
| User home |
| Result | Action |
|---|
| Found | Read, parse, apply settings. 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
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 | | | | Translation target language |
| Mode | | | | Translation mode |
| Audience | | | | Target reader profile |
| Style | | | | Translation style preference |
| Chunk threshold | | | — | Word count to trigger chunked translation |
| Chunk max words | | | — | Max words per chunk |
Modes
| Mode | Flag | Steps | When to Use |
|---|
| Quick | | Translate | Short texts, informal content, quick tasks |
| Normal | (default) | Analyze → Translate | Articles, blog posts, general content |
| Refined | | Analyze → Translate → Review → Polish | Publication-quality, important documents |
Default mode: Normal (can be overridden in EXTEND.md
setting).
Style presets — control the voice and tone of the translation (independent of audience):
| Value | Description | Effect |
|---|
| Engaging narrative flow (default) | Draws readers in, smooth transitions, vivid phrasing |
| Professional, structured | Neutral tone, clear organization, no colloquialisms |
| Precise, documentation-style | Concise, terminology-heavy, minimal embellishment |
| Close to original structure | Minimal restructuring, preserves source sentence patterns |
| Scholarly, rigorous | Formal register, complex clauses OK, citation-aware |
| Concise, results-focused | Action-oriented, executive-friendly, bullet-point mindset |
| Preserves and adapts humor | Witty, playful, recreates comedic effect in target language |
| Casual, spoken-like | Friendly, approachable, as if explaining to a friend |
| 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.
Usage
/translate [--mode quick|normal|refined] [--from <lang>] [--to <lang>] [--audience <audience>] [--style <style>] [--glossary <file>] <source>
- : File path, URL, or inline text
- : Source language (auto-detect if omitted)
- : Target language (from EXTEND.md or default )
- : Target reader profile (from EXTEND.md or default )
- : Translation style (from EXTEND.md or default )
- : Additional glossary file to merge with EXTEND.md glossary
Audience presets:
| Value | Description | Effect |
|---|
| General readers (default) | Plain language, more translator's notes for jargon |
| Developers / engineers | Less annotation on common tech terms |
| Researchers / scholars | Formal register, precise terminology |
| Business professionals | Business-friendly tone, explain tech concepts |
Custom audience descriptions are also accepted, e.g.,
.
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
(inline) + EXTEND.md
(external files, paths relative to EXTEND.md location) + built-in glossary +
file (CLI overrides all)
Step 2: Materialize Source & Create Output Directory
Materialize source (file as-is, inline text/URL → save to
), then create output directory:
{source-dir}/{source-basename}-{target-lang}/
. Detect source language if
not specified.
Full details: references/workflow-mechanics.md
Output directory contents (all intermediate and final files go here):
| File | Mode | Description |
|---|
| All | Final translation (always this name) |
| Normal, Refined | Content analysis (domain, tone, terminology) |
| Normal, Refined | Assembled translation prompt |
| Refined | Initial draft before review |
| Refined | Critical review findings (diagnosis only) |
| Refined | Revised translation based on critique |
| 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,
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 (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 in the output directory (shared context only, no task instructions)
- Draft translation via subagents (if Agent tool available):
- Spawn one subagent per chunk, all in parallel (Part 2 of the template)
- Each subagent reads for shared context, receives chunk position info (chunk N of M + brief context of where it sits in the argument), translates its chunk, saves to
- Consistency is guaranteed by the shared (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
- Merge: Once all subagents complete, combine translated chunks in order. If exists, prepend it. Save as (refined) or (normal)
- All intermediate files (source chunks + translated chunks) are preserved in
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 prefix (camelCase: →, →, etc.), add translated values as new top-level fields (skip if body has H1), keep other fields as-is
Quick Mode
Translate directly → save to
. Apply all translation principles above.
Normal Mode
- Analyze → (domain, tone, terminology, translation challenges)
- Assemble prompt → (translation instructions with context, glossary, challenges)
- Translate (following ) →
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
(rename current
),
,
, and updated
.
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 → (domain, tone, terminology, translation challenges)
- Assemble prompt → (translation instructions with inlined context)
- Draft → (initial translation with translator's notes; from subagent if chunked)
- Critical review → (diagnosis only: accuracy, Europeanized language, strategy execution, expression issues)
- Revision → (apply all critique findings to produce revised translation)
- Polish → (final publication-quality translation)
Each step reads the previous step's file and builds on it.
Step 5: Output
Final translation is always at
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):
text
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.