Repository navigation
AI Translation
📄 Mirrors
docs/ai-translation.mdin the main repo — the repo version is canonical.
Status: planned / pre-release. This page documents the intended API of next-tongue. Nothing is published yet; names may change before v1.0. See ROADMAP.
tongue translate is a built-in, optional workflow: you bring your own key to any OpenAI-compatible Chat Completions endpoint (OpenAI, Azure OpenAI, OpenRouter, Together, Groq, xAI, Mistral, local Ollama/LM Studio/vLLM, …). There is no next-tongue service, no account, no telemetry.
translate: {
baseURL: 'https://api.openai.com/v1',
model: 'gpt-4.1-mini',
apiKeyEnv: 'TONGUE_API_KEY',
glossary: './tongue.glossary.json',
lockfile: './tongue.lock',
context: 'Consumer banking app. Friendly, concise. Informal "du" in German.',
}Local example: baseURL: 'http://localhost:11434/v1', model: 'qwen2.5:14b' (key may be any string).
{
"terms": {
"Workspace": { "de": "Workspace", "fr": "Espace de travail", "note": "Product term" },
"next-tongue": { "doNotTranslate": true }
}
}Terms are injected into the prompt; after translation, tongue translate verifies glossary terms appear and flags violations.
Commit it. Per locale and key it records a hash of the source text, a hash of the target text, model and timestamp:
{ "version": 1, "de": { "home.title": { "source": "sha256:…", "target": "sha256:…", "model": "gpt-4.1-mini", "at": "2026-10-14T10:00:00Z" } } }- Source changed → key is stale:
tongue checkflags it as outdated (stale, severitystrict.stale),tongue translateretranslates it andtongue export --missing-onlyincludes it (#42). Hashes are SHA-256 vianode:crypto. - Target changed by a human (hash differs) → treated as human-edited and never overwritten unless
--retranslate.
$meta (description, screenshot link, maxLength) is included in prompts; outputs longer than maxLength are retried once, then reported. See Translator workflow.
Before sending, {args} and tags are masked with opaque tokens and restored afterwards; a restored output that changes them is rejected. translate.maxTokens / --max-cost cap spend per run, and in CI (CI=true) --review is the default. Requests use global fetch only (ADR 0012).
- Every LLM output is parsed as ICU and compared with the source: args, tags and plural categories (per target-locale CLDR rules) must match, otherwise it is retried once, then reported and skipped.
- Only messages and descriptions are sent; never source code, env, or file paths beyond key names.
-
--dry-runshows the plan and estimated tokens without calling the API. - The API key is read from the env var only and never written to disk or logs.
tongue translate --review in a PR → humans review *.review.json → tongue translate --accept merges them.
Guides
- Getting Started
- Configuration
- Routing and Proxy
- Server Components
- Client Components
- Server Actions
- ICU Messages
- Type Safety
- Cache Components and PPR
- Static Export
- Metadata SEO and hreflang
- Database and CMS Messages
- Dev Tools
- Translator Workflow
- Per-user Preferred Language
- CLI
- AI Translation
- Testing
- VS Code Extension
- Migration from next intl
- Migration from next international (deferred)
Reference