references/config/extend-schema.md
3.5 KB查看排版效果| 1 | # EXTEND.md Schema for baoyu-translate |
| 2 | |
| 3 | ## Format |
| 4 | |
| 5 | EXTEND.md uses YAML format: |
| 6 | |
| 7 | ```yaml |
| 8 | # Default target language (ISO code or common name) |
| 9 | target_language: zh-CN |
| 10 | |
| 11 | # Default translation mode |
| 12 | default_mode: normal # quick | normal | refined |
| 13 | |
| 14 | # Target audience (affects annotation depth and register) |
| 15 | audience: general # general | technical | academic | business | or custom string |
| 16 | |
| 17 | # Translation style preference |
| 18 | style: storytelling # storytelling | formal | technical | literal | academic | business | humorous | conversational | elegant | or custom string |
| 19 | |
| 20 | # Word count threshold to trigger chunked translation |
| 21 | chunk_threshold: 4000 |
| 22 | |
| 23 | # Max words per chunk |
| 24 | chunk_max_words: 5000 |
| 25 | |
| 26 | # Custom glossary (merged with built-in glossary) |
| 27 | # CLI --glossary flag overrides these |
| 28 | # Supports inline entries and/or file paths |
| 29 | glossary: |
| 30 | - from: "Reinforcement Learning" |
| 31 | to: "强化学习" |
| 32 | - from: "Transformer" |
| 33 | to: "Transformer" |
| 34 | note: "Keep English" |
| 35 | |
| 36 | # Load glossary from external file(s) |
| 37 | # Supports absolute path or relative to EXTEND.md location |
| 38 | # File format: markdown table with | from | to | note | columns, |
| 39 | # or YAML list of {from, to, note} entries |
| 40 | glossary_files: |
| 41 | - ./my-glossary.md |
| 42 | - /path/to/shared-glossary.yaml |
| 43 | |
| 44 | # Language-pair specific glossaries |
| 45 | glossaries: |
| 46 | en-zh: |
| 47 | - from: "AI Agent" |
| 48 | to: "AI 智能体" |
| 49 | ja-zh: |
| 50 | - from: "人工知能" |
| 51 | to: "人工智能" |
| 52 | ``` |
| 53 | |
| 54 | ## Fields |
| 55 | |
| 56 | | Field | Type | Default | Description | |
| 57 | |-------|------|---------|-------------| |
| 58 | | `target_language` | string | `zh-CN` | Default target language code | |
| 59 | | `default_mode` | string | `normal` | Default translation mode (`quick` / `normal` / `refined`) | |
| 60 | | `audience` | string | `general` | Target reader profile (`general` / `technical` / `academic` / `business` / custom) | |
| 61 | | `style` | string | `storytelling` | Translation style (`storytelling` / `formal` / `technical` / `literal` / `academic` / `business` / `humorous` / `conversational` / `elegant` / custom) | |
| 62 | | `chunk_threshold` | number | `4000` | Word count threshold to trigger chunked translation | |
| 63 | | `chunk_max_words` | number | `5000` | Max words per chunk | |
| 64 | | `glossary` | array | `[]` | Universal glossary entries (inline) | |
| 65 | | `glossary_files` | array | `[]` | External glossary file paths (absolute or relative to EXTEND.md) | |
| 66 | | `glossaries` | object | `{}` | Language-pair specific glossary entries | |
| 67 | |
| 68 | ## Glossary Entry |
| 69 | |
| 70 | | Field | Required | Description | |
| 71 | |-------|----------|-------------| |
| 72 | | `from` | yes | Source term | |
| 73 | | `to` | yes | Target translation | |
| 74 | | `note` | no | Usage note (e.g., "Keep English", "Only in tech context") | |
| 75 | |
| 76 | ## Glossary File Format |
| 77 | |
| 78 | External glossary files (`glossary_files`) support two formats: |
| 79 | |
| 80 | **Markdown table** (`.md`): |
| 81 | ```markdown |
| 82 | | from | to | note | |
| 83 | |------|----|------| |
| 84 | | Reinforcement Learning | 强化学习 | | |
| 85 | | Transformer | Transformer | Keep English | |
| 86 | ``` |
| 87 | |
| 88 | **YAML list** (`.yaml` / `.yml`): |
| 89 | ```yaml |
| 90 | - from: "Reinforcement Learning" |
| 91 | to: "强化学习" |
| 92 | - from: "Transformer" |
| 93 | to: "Transformer" |
| 94 | note: "Keep English" |
| 95 | ``` |
| 96 | |
| 97 | Paths can be absolute or relative to the EXTEND.md file location. |
| 98 | |
| 99 | ## Priority |
| 100 | |
| 101 | 1. CLI `--glossary` file entries |
| 102 | 2. EXTEND.md `glossaries[pair]` entries |
| 103 | 3. EXTEND.md `glossary` entries (inline) |
| 104 | 4. EXTEND.md `glossary_files` entries (in listed order, later files override earlier) |
| 105 | 5. Built-in glossary (e.g., `references/glossary-en-zh.md`) |
| 106 | |
| 107 | Later entries override earlier ones for the same source term. |
文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。

