Solutions · Text Generation · Text translation

Translate text without leaving your hardware.

The TextTranslation engine translates plain strings, image content, and document attachments across 100+ languages. Layout and formatting are preserved during translation, custom system prompts and few-shot examples shape the output for your domain, and every byte stays on the machine that ran the inference.

Format-preserving Streaming progress events 100% on-device

Translate(text, target)

Translate a string to the target Language.

TranslateAsync(...)

Async overloads with cancellation tokens.

TranslationProgress

Token-by-token progress events for streaming UIs.

Attachment input

Translate text inside PDFs, Office docs, and images.

Engine overview

Context-aware translation that preserves structure.

Cloud translation APIs typically return a flat translated string and discard the layout of the input. TextTranslation takes a different approach: it preserves paragraph breaks, list bullets, code blocks, table cells, and inline emphasis so a translated document remains usable in your application without a layout post-process.

Format preservation

Markdown, HTML, and PDF structure are kept intact during translation. Paragraph and list boundaries map 1:1 between source and target.

Custom system prompts

Override the default translator system prompt to enforce house style, glossary terms, register (formal vs casual), or domain conventions.

Few-shot examples

Pass (input, output) pairs alongside your translation request to teach the model your preferred phrasing for jargon, brand terms, and idioms.

Streaming progress

Subscribe to TranslationProgress for token-by-token updates. Build responsive translation UIs that display output as the model generates.

Multimodal input

Translate text inside images and PDFs through the same API. The model performs OCR or VLM analysis transparently when given an Attachment.

Sync and async

Both blocking and Task-based overloads. Async variants accept CancellationToken so long translations integrate cleanly with UI patterns.

Code samples

Three translation patterns.

From a single line of text to a streaming multi-paragraph translation, the same class handles each shape.

BasicTranslation.cs
using LMKit.Model;
using LMKit.Translation;
using LMKit.TextGeneration;

var model = LM.LoadFromModelID("qwen3.5:4b");
var translator = new TextTranslation(model);

string source = "The forecast suggests heavy snowfall across the highlands.";
string german = translator.Translate(source, Language.German);
string japanese = translator.Translate(source, Language.Japanese);

Console.WriteLine(german);
Console.WriteLine(japanese);
Training data

Use built-in datasets for fine-tuning.

TextTranslation.GetTrainingData returns curated training pairs you can feed into LoraFinetuning to specialise a base model for your translation domain. Combine with custom few-shot examples at inference time for the best of both worlds: the LoRA learns your structural patterns, the few-shot keeps glossary terms exact.

Applications

Where on-device translation wins.

Confidential documents

Legal contracts, NDAs, internal memos, M&A material. Translate without sending text to any third-party endpoint.

Air-gapped deployments

Defense, research labs, isolated facilities. Translation works without any internet connectivity.

High-volume support

Translate millions of customer messages with a fixed license cost instead of per-token cloud fees that scale linearly.

Localized authoring tools

Embed real-time translation inside desktop and mobile apps. Sub-second latency without round-trips.

Document intelligence

Combine with DocumentRag and OCR to translate scanned PDFs, invoices, and contracts inline.

Glossary-faithful translation

Pin brand names, product SKUs, and technical jargon via few-shot examples. Beat generic cloud translators on domain consistency.

Developer Resources

API reference.

TextTranslation

Main class. Translate and TranslateAsync overloads accept text, target Language, optional TranslationPromptData, and optional CancellationToken.

View documentation

TranslationPromptData

Pair a custom SystemPrompt with a list of (Input, Output) few-shot examples. Override per-call to specialise translation behaviour.

View documentation

TranslationProgress

Event fired with each generated token. Use for streaming UI updates and progress bars.

View documentation

Need to identify the source language first? See the Language Detection page.

Translate without cloud cost or risk.

Fixed license, unlimited tokens, zero data egress.

Get Community Edition Download