{
  "schema": "leumas.docs.page/1",
  "id": "adapter:domain/translator",
  "slug": "adapters/domain/translator",
  "kind": "capabilities",
  "bucket": "package",
  "title": "translator",
  "name": "translator",
  "eyebrow": null,
  "chip": null,
  "summary": "Language & translation microservice: translate ({text,to,from?}) uses an LLM as the PRIMARY engine and gracefully falls back to a small built-in phrase dictionary + passthrough when no model is...",
  "keywords": [
    "translator",
    "translation",
    "passthrough",
    "detectlanguage",
    "spanish",
    "translator api",
    "glossaryapply",
    "tonepreservenote"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# translator\n\nLanguage & translation microservice. Translate text, detect languages, transliterate scripts, and\nlocalize with a glossary and tone-preservation notes.\n\n`translate` and `batch` use an **LLM as the primary engine** (via `../_shared/llm.js`). When no model\nis reachable they gracefully fall back to a small built-in phrase dictionary, then to passthrough —\nalways tagged with `{ mode, note }` so nothing throws:\n\n- `mode: 'llm'` — a model translated it.\n- `mode: 'dictionary'` — partial phrase-dictionary hit (offline). `note` tells you to install a model.\n- `mode: 'passthrough'` — source returned unchanged (offline, no dictionary hit). `note` says why.\n\nThe other four tools are **pure and fully offline**.\n\n## Tools\n\n| Tool | Input | Returns |\n|---|---|---|\n| `translate` | `{ text, to, from?, glossary? }` | `{ translation, from, to, mode, note? }` |\n| `detectLanguage` | `{ text }` | `{ language, code, confidence, reliable, scores }` |\n| `glossaryApply` | `{ text, glossary }` | `{ text, applied, replacements }` |\n| `tonePreserveNote` | `{ text }` | `{ register, notes, signals }` — what to keep when translating |\n| `batch` | `{ texts:[..], to, from? }` | `{ results:[{translation,mode}], modes }` |\n| `romanize` | `{ text }` | `{ text, transliterated, isAscii }` — accented Latin / Cyrillic / Greek → ASCII |\n\n## Usage\n\n```js\nimport pack from './index.js';\n\npack.adapters.detectLanguage({ text: 'Le chat est sur la table' });\n// -> { language:'French', code:'fr', confidence, reliable:true }\n\npack.adapters.glossaryApply({ text: 'Our SDK powers the API', glossary: { SDK: 'toolkit', API: 'interface' } });\n// -> { text:'Our toolkit powers the interface', applied:[...] }\n\npack.adapters.romanize({ text: 'Cafédóttir Москва Αθήνα' });\n// -> { text:'Cafedottir Moskva Athina', isAscii:true }\n\nawait pack.adapters.translate({ text: 'Hello, thank you', to: 'es' });\n// with a model -> { mode:'llm', translation:'Hola, gracias' }\n// offline      -> { mode:'dictionary', translation:'Hola, gracias', note:'...install a model...' }\n```\n\n`to`/`from` accept codes (`es`, `fr`) or names (`spanish`, `French`). Pass `options:{ useLlm:false }`\nto force the offline path.\n\n## DRY boundaries\n\n- Generic tokenize / sentiment / readability of prose lives in **`nlp`** / **`a-text`**; hex/base64\n  DATA encoding lives in **`a-transformation`**. This pack owns **language** modeling: translation\n  routing, language identification, transliteration, glossary/tone localization.\n- `detectLanguage` and `glossaryApply` are deterministic and never call the network.\n- Self-contained: the only import is `../_shared/llm.js`.\n",
  "source": {
    "path": "shared/engines/adapters/domain/translator/README.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 2877,
    "hash": "cc9aa483842fe5892d7be94955d57d24cbb86c14"
  },
  "urls": {
    "html": "/p/adapters/domain/translator",
    "json": "/docs/adapters/domain/translator.json",
    "md": "/docs/adapters/domain/translator.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  }
}
