# Translator
A LangBot skill for faithful, structure-preserving translation between languages.
## What it does
- Translates messages and documents while keeping markdown/code formatting intact.
- Masks code blocks, inline code, URLs, and placeholders so they survive translation untouched.
- Keeps terminology consistent via a glossary.
- Validates the result so structure (headings, links, placeholders) is preserved.
## Supported languages
Works for any language pair. Includes style notes for the locales LangBot ships:
English (en_US), Simplified Chinese (zh_Hans), Traditional Chinese (zh_Hant),
Japanese (ja_JP), Thai (th_TH), Vietnamese (vi_VN), Spanish (es_ES), Russian (ru_RU).
## Files
| File | Purpose |
|------|---------|
| `SKILL.md` | Instructions the agent receives on activation |
| `scripts/protect.py` | Mask/restore non-translatable spans around a translation |
| `scripts/check.py` | Verify a translation preserved structure and protected spans |
| `templates/glossary.csv` | Starter term glossary for consistency |
| `references/style-guide.md` | Per-language tone and formatting conventions |
## License
Apache-2.0.
---
name: translator
display_name: Translator
description: "Translate text and documents between languages while preserving tone, formatting, terminology, and markdown/code structure. Use when the user asks to translate content, localize a document, build a glossary-consistent translation, or convert between languages such as English, Chinese (Simplified/Traditional), Japanese, Thai, Vietnamese, Spanish, or Russian. Do NOT translate inside code blocks, URLs, or placeholder tokens."
license: Apache-2.0
---
# Translator
Translate text faithfully across languages while keeping the original's tone, register, structure, and terminology intact.
## When to use
Use this skill when the user wants to:
- Translate a message, paragraph, or whole document between languages.
- Localize markdown/HTML while keeping formatting, links, and code intact.
- Produce a translation that stays consistent with an existing glossary of terms.
## Execution steps
1. **Detect or confirm languages.** Identify the source language; confirm the target language if it is not explicit. If the source has mixed languages, translate only the natural-language parts.
2. **Protect non-translatable spans.** Run `scripts/protect.py` to mask fenced/inline code, URLs, and `{placeholder}`-style tokens before translation, then restore them after. This prevents the model from corrupting code or links.
3. **Apply the glossary.** If the user supplies term mappings (or you build one), load `templates/glossary.csv`, and translate listed terms consistently everywhere they appear.
4. **Translate.** Render the text in the target language matching the original register (formal/casual), preserving markdown structure (headings, lists, tables, emphasis).
5. **Verify.** Run `scripts/check.py` to confirm the output preserved all protected spans, link counts, and heading counts. Flag any source phrase that is genuinely ambiguous instead of guessing.
## Rules
- Never translate text inside code blocks, inline code, or URLs.
- Keep placeholders (`{name}`, `%s`, `:var`) byte-for-byte identical.
- Maintain one consistent rendering per glossary term across the whole document.
- Match the tone and formality of the source; do not "improve" or summarize.
## Available resources
- `scripts/protect.py` — mask/restore code, URLs, and placeholders around a translation pass.
- `scripts/check.py` — validate that a translation preserved structure and protected spans.
- `templates/glossary.csv` — starter glossary (source term, target term) for consistency.
- `references/style-guide.md` — per-language tone, punctuation, and spacing conventions.
Translator by langbot-team
Translate text between languages while preserving tone, formatting, and terminology. Use when the user asks to translate content.
Loading...