feat(baoyu-translate): expand translation style presets from 4 to 9 with CLI flag support

Add 5 new style presets (academic, business, humorous, conversational,
elegant) to existing options. Wire --style CLI flag, update subagent
prompt template with style section, and document in both READMEs.
This commit is contained in:
Jim Liu 宝玉 2026-03-06 02:33:25 -06:00
parent bce96e411d
commit be2cbecfb0
7 changed files with 159 additions and 12 deletions

View File

@ -741,7 +741,7 @@ Format plain text or markdown files with proper frontmatter, titles, summaries,
#### baoyu-translate
Translate articles and documents between languages with three modes: quick (direct), normal (analysis-informed), and refined (full publication-quality workflow).
Translate articles and documents between languages with three modes: quick (direct), normal (analysis-informed), and refined (full publication-quality workflow with review and polish).
```bash
# Normal mode (default) - analyze then translate
@ -752,8 +752,31 @@ Translate articles and documents between languages with three modes: quick (dire
# Refined mode - full workflow with review and polish
/translate article.md --mode refined --to zh-CN
# Translate a URL
/translate https://example.com/article --to zh-CN
# Specify audience
/translate article.md --to zh-CN --audience technical
# Specify style
/translate article.md --to zh-CN --style humorous
# With additional glossary
/translate article.md --to zh-CN --glossary my-terms.md
```
**Options**:
| Option | Description |
|--------|-------------|
| `<source>` | File path, URL, or inline text |
| `--mode <mode>` | `quick`, `normal` (default), `refined` |
| `--from <lang>` | Source language (auto-detect if omitted) |
| `--to <lang>` | Target language (default: `zh-CN`) |
| `--audience <type>` | Target reader profile (default: `general`) |
| `--style <style>` | Translation style (default: `storytelling`) |
| `--glossary <file>` | Additional glossary file |
**Modes**:
| Mode | Steps | Use Case |
|------|-------|----------|
@ -761,7 +784,40 @@ Translate articles and documents between languages with three modes: quick (dire
| Normal | Analyze → Translate | Articles, blog posts |
| Refined | Analyze → Translate → Review → Polish | Publication-quality documents |
**Features**: Custom glossaries via EXTEND.md, audience-aware translation (general/technical/academic/business), automatic chunking for long documents with parallel subagent translation.
After normal mode completes, you can reply "继续润色" or "refine" to continue with review and polish steps.
**Audience Presets**:
| Value | Description |
|-------|-------------|
| `general` | General readers (default) — plain language, more translator's notes |
| `technical` | Developers / engineers — less annotation on common tech terms |
| `academic` | Researchers / scholars — formal register, precise terminology |
| `business` | Business professionals — business-friendly tone |
Custom audience descriptions are also accepted, e.g., `--audience "AI-interested general readers"`.
**Style Presets**:
| Value | Description |
|-------|-------------|
| `storytelling` | Engaging narrative flow (default) — smooth transitions, vivid phrasing |
| `formal` | Professional, structured — neutral tone, no colloquialisms |
| `technical` | Precise, documentation-style — concise, terminology-heavy |
| `literal` | Close to original structure — minimal restructuring |
| `academic` | Scholarly, rigorous — formal register, complex clauses OK |
| `business` | Concise, results-focused — action-oriented, executive-friendly |
| `humorous` | Preserves and adapts humor — witty, recreates comedic effect |
| `conversational` | Casual, spoken-like — friendly, as if explaining to a friend |
| `elegant` | Literary, polished prose — aesthetically refined, carefully crafted |
Custom style descriptions are also accepted, e.g., `--style "poetic and lyrical"`.
**Features**:
- Custom glossaries via EXTEND.md with built-in EN→ZH glossary
- Audience-aware translation with adjustable annotation depth
- Automatic chunking for long documents (4000+ words) with parallel subagent translation
- Figurative language interpreted by meaning, not word-for-word
- Translator's notes for cultural/domain-specific references
- Output directory with all intermediate files preserved
## Environment Configuration

View File

@ -752,8 +752,31 @@ AI 驱动的生成后端。
# 精翻模式 - 完整工作流,含审校与润色
/translate article.md --mode refined --to zh-CN
# 翻译 URL
/translate https://example.com/article --to zh-CN
# 指定受众
/translate article.md --to zh-CN --audience technical
# 指定风格
/translate article.md --to zh-CN --style humorous
# 附加术语表
/translate article.md --to zh-CN --glossary my-terms.md
```
**选项**
| 选项 | 说明 |
|------|------|
| `<source>` | 文件路径、URL 或行内文本 |
| `--mode <mode>` | `quick`、`normal`(默认)、`refined` |
| `--from <lang>` | 源语言(省略则自动检测) |
| `--to <lang>` | 目标语言(默认:`zh-CN` |
| `--audience <type>` | 目标读者(默认:`general` |
| `--style <style>` | 翻译风格(默认:`storytelling` |
| `--glossary <file>` | 附加术语表文件 |
**模式**
| 模式 | 步骤 | 适用场景 |
|------|------|----------|
@ -761,7 +784,40 @@ AI 驱动的生成后端。
| 标准 | 分析 → 翻译 | 文章、博客 |
| 精翻 | 分析 → 翻译 → 审校 → 润色 | 出版级文档 |
**特性**:通过 EXTEND.md 自定义术语表、面向受众的翻译(通用/技术/学术/商务)、长文档自动分块并行翻译。
标准模式完成后可回复「继续润色」或「refine」继续审校润色步骤。
**受众预设**
| 值 | 说明 |
|----|------|
| `general` | 普通读者(默认)— 通俗语言,更多译注 |
| `technical` | 开发者/工程师 — 常见技术术语少加注释 |
| `academic` | 研究者/学者 — 正式语体,精确术语 |
| `business` | 商务人士 — 商务友好语气 |
也支持自定义受众描述,如 `--audience "对 AI 感兴趣的普通读者"`
**风格预设**
| 值 | 说明 |
|----|------|
| `storytelling` | 叙事流畅(默认)— 过渡自然,表达生动 |
| `formal` | 正式、结构化 — 中性语气,无口语化表达 |
| `technical` | 精确、文档风格 — 简洁,术语密集 |
| `literal` | 贴近原文结构 — 最小化重构 |
| `academic` | 学术、严谨 — 正式语体,复杂从句可接受 |
| `business` | 简洁、结果导向 — 行动导向,高管友好 |
| `humorous` | 保留幽默感 — 诙谐,在目标语言中重现喜剧效果 |
| `conversational` | 口语化、亲切 — 友好,如同朋友间解释 |
| `elegant` | 文学性、优雅 — 精心雕琢,注重韵律美感 |
也支持自定义风格描述,如 `--style "诗意而抒情"`
**特性**
- 通过 EXTEND.md 自定义术语表,内置英中术语表
- 面向受众的翻译,可调节注释深度
- 长文档4000+ 词)自动分块并行翻译
- 比喻和修辞按意译而非逐字翻译
- 为文化/专业术语添加译注
- 输出目录保留所有中间文件
## 环境配置

View File

@ -62,7 +62,7 @@ All configurable values in one place. EXTEND.md overrides these; CLI flags overr
| 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` | | Translation style preference |
| 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 |
@ -76,6 +76,22 @@ All configurable values in one place. EXTEND.md overrides these; CLI flags overr
**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
@ -89,13 +105,14 @@ If user responds, continue with review → polish steps (same as refined mode St
## Usage
```
/translate [--mode quick|normal|refined] [--from <lang>] [--to <lang>] [--audience <audience>] [--glossary <file>] <source>
/translate [--mode quick|normal|refined] [--from <lang>] [--to <lang>] [--audience <audience>] [--style <style>] [--glossary <file>] <source>
```
- `<source>`: File path, URL, or inline text
- `--from`: Source language (auto-detect if omitted)
- `--to`: Target language (from EXTEND.md or default `zh-CN`)
- `--audience`: Target reader profile (from EXTEND.md or default `general`)
- `--style`: Translation style (from EXTEND.md or default `storytelling`)
- `--glossary`: Additional glossary file to merge with EXTEND.md glossary
**Audience presets**:

View File

@ -15,7 +15,7 @@ default_mode: normal # quick | normal | refined
audience: general # general | technical | academic | business | or custom string
# Translation style preference
style: storytelling # storytelling | formal | technical | literal
style: storytelling # storytelling | formal | technical | literal | academic | business | humorous | conversational | elegant | or custom string
# Word count threshold to trigger chunked translation
chunk_threshold: 4000
@ -49,7 +49,7 @@ glossaries:
| `target_language` | string | `zh-CN` | Default target language code |
| `default_mode` | string | `normal` | Default translation mode (`quick` / `normal` / `refined`) |
| `audience` | string | `general` | Target reader profile (`general` / `technical` / `academic` / `business` / custom) |
| `style` | string | `storytelling` | Translation style preference |
| `style` | string | `storytelling` | Translation style (`storytelling` / `formal` / `technical` / `literal` / `academic` / `business` / `humorous` / `conversational` / `elegant` / custom) |
| `chunk_threshold` | number | `4000` | Word count threshold to trigger chunked translation |
| `chunk_max_words` | number | `5000` | Max words per chunk |
| `glossary` | array | `[]` | Universal glossary entries |

View File

@ -99,15 +99,27 @@ header: "Style"
question: "Translation style?"
options:
- label: "Storytelling (Recommended)"
description: "Engaging, narrative-like flow"
description: "Engaging narrative flow, smooth transitions"
- label: "Formal"
description: "Professional, structured"
description: "Professional, structured, neutral tone"
- label: "Technical"
description: "Precise, documentation-style"
description: "Precise, documentation-style, concise"
- label: "Literal"
description: "Close to original structure"
- label: "Academic"
description: "Scholarly, rigorous, formal register"
- label: "Business"
description: "Concise, results-focused, action-oriented"
- label: "Humorous"
description: "Preserves humor, witty, playful"
- label: "Conversational"
description: "Casual, friendly, spoken-like"
- label: "Elegant"
description: "Literary, polished, aesthetically refined"
```
Note: User may type a custom style description.
### Question 5: Save Location
```yaml
@ -141,7 +153,7 @@ options:
target_language: [zh-CN/zh-TW/en/ja/...]
default_mode: [quick/normal/refined]
audience: [general/technical/academic/business/custom]
style: [storytelling/formal/technical/literal]
style: [storytelling/formal/technical/literal/academic/business/humorous/conversational/elegant]
# Custom glossary (optional) — add your own term translations here
# glossary:

View File

@ -246,7 +246,7 @@ Final pass on `05-revision.md` for publication quality:
- Read the entire translation as a standalone piece — does it flow as native content?
- Smooth any remaining rough transitions between paragraphs
- Ensure the narrative voice is consistent throughout
- For storytelling-style content: ensure the narrative flow draws readers in
- Apply the selected translation style consistently: storytelling should flow like a narrative, formal should maintain neutral professionalism, humorous should land jokes naturally in the target language, etc.
- Final scan for surviving literal metaphors or flattened emotions: any figurative expression that still reads as "translated" rather than "written" should be recast into natural target-language expression
- Final consistency check on terminology across the full text
- Verify formatting is preserved correctly (headings, bold, links, code blocks)

View File

@ -19,6 +19,12 @@ You are a professional translator. Your task is to translate markdown content fr
{audience description}
## Translation Style
{style description — e.g., "storytelling: engaging narrative flow, smooth transitions, vivid phrasing" or custom style from user}
Apply this style consistently: it determines the voice, tone, and sentence-level choices throughout the translation. Style is independent of audience — a technical audience can still get a storytelling-style translation, or a general audience can get a formal one.
## Content Background
{Inlined from 01-analysis.md if analysis exists: quick summary, core argument, author background, writing context, tone assessment, figurative language & metaphor mapping.}