Machine translation APIs deliver speed and consistency, but they struggle with domain terminology, nuanced tone, and context-dependent phrasing. Large language models handle those tasks well, yet they hallucinate, drop placeholders, and resist deterministic control. Neither engine alone satisfies the requirements of production localization pipelines that must be fast, accurate, and auditable.
A hybrid pipeline combines both: the MT engine handles bulk translation with glossary enforcement and tag preservation, while a constrained LLM performs terminology extraction, quality estimation, or targeted fixups. The challenge is designing the integration so that each component does what it does best without introducing new failure modes. This article walks through the architecture, API-level implementation details, and validation safeguards you need to ship a hybrid pipeline that is safe, cost-efficient, and repeatable.
If you're evaluating how to bring this kind of pipeline into your localization stack, explore how Ollang's API layer can accelerate your integration: Get a guided integration plan.
Why Combine LLMs and MT Engines?
MT engines like Google Cloud Translation, DeepL, and Amazon Translate are optimized for throughput, consistency, and format preservation. They handle high volumes, respect glossary constraints, and return structurally predictable output. But they can produce stiff translations, miss domain-specific nuance, and lack the ability to reason about whether a translation is contextually appropriate.
LLMs excel at exactly those tasks. They can evaluate whether a translated sentence sounds natural, flag terminology mismatches, and rewrite awkward phrasing. However, they introduce risks that are unacceptable in production: they may invent content, silently drop format tags, or return output that differs structurally from the source.
A hybrid pipeline assigns each engine to its strengths:
- MT engine: Produces the base translation with glossary enforcement, tag preservation, and deterministic behavior.
- LLM: Handles pre-processing (terminology extraction, context enrichment) and post-processing (quality estimation, targeted fixups) under strict constraints.
The result is translation quality that exceeds what either engine achieves alone, with auditability and safety guarantees that production workflows demand.
Pre-Processing with an LLM: Terminology and Placeholder Extraction
Before a source segment reaches the MT engine, an LLM can perform two high-value pre-processing tasks: extracting domain terminology and identifying placeholders that must be protected during translation.
Ollang's API layer can centralize these extraction and tokenization steps so the same glossary and placeholder mappings are applied consistently across MT providers.
Extracting Domain Terminology
Feed source segments to the LLM with a prompt that constrains its output to a structured terminology list. The goal is not translation, it is identification of terms that the MT engine should handle via glossary lookup rather than general inference.
{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a terminology extractor. Given source text, return a JSON array of domain-specific terms that require controlled translation. Do not translate. Do not explain."
},
{
"role": "user",
"content": "The API rate limiter enforces a sliding window algorithm with configurable burst capacity."
}
],
"response_format": { "type": "json_object" }
}
A well-constrained prompt returns structured output like:
{
"terms": ["rate limiter", "sliding window algorithm", "burst capacity"]
}
These extracted terms are then matched against your translation memory or terminology database. Approved translations are passed to the MT engine as glossary entries.
Protecting Placeholders and Markup
Source content frequently contains elements that must pass through translation untouched: ICU message format variables ({count, plural, one {# item} other {# items}}), HTML tags (<strong>, <a href="...">), Markdown formatting, and software placeholders like %s or {{username}}.
The LLM can identify and tag these elements before the MT call, but a more reliable approach is regex-based extraction combined with LLM verification. Use deterministic pattern matching to find placeholders, then optionally ask the LLM to confirm that the identified elements are non-translatable.
A practical pattern:
1. Run regex extraction to identify all placeholders and tags in the source segment.
2. Replace each with a numbered token (for example, <x id="1"/>) that MT engines are trained to preserve.
3. Store the mapping in a lookup table.
4. After translation, restore original placeholders using the mapping.
This tokenization step is critical. MT engines handle XML-like tokens far more reliably than raw ICU syntax or nested HTML.
Passing Glossaries and Terminology via MT APIs
Each major MT API supports glossary or terminology injection, but the mechanisms differ significantly. Passing the right terms through the right parameter is what turns generic MT output into domain-accurate translation.
DeepL: glossary_id
DeepL requires you to create a glossary resource first, then reference it by ID in each translation request. Glossaries are language-pair specific.
curl -X POST https://api-free.deepl.com/v2/translate \
-H "Authorization: DeepL-Auth-Key YOUR_KEY" \
-d "text=The rate limiter enforces burst capacity." \
-d "source_lang=EN" \
-d "target_lang=DE" \
-d "glossary_id=abc123-def456"
DeepL glossaries support one-to-one term mappings and are enforced deterministically, the engine will use the glossary translation whenever the source term appears.
Google Cloud Translation: glossaryConfig
Google's Advanced (v3) API accepts a glossary configuration object that references a glossary resource stored in your Google Cloud project.
{
"sourceLanguageCode": "en",
"targetLanguageCode": "fr",
"contents": ["The sliding window algorithm resets every 60 seconds."],
"glossaryConfig": {
"glossary": "projects/my-project/locations/us-central1/glossaries/my-glossary",
"ignoreCase": true
}
}
Google supports unidirectional and equivalent-set glossaries, giving you flexibility for terms that translate differently depending on direction.
Amazon Translate: terminologyNames
Amazon Translate accepts one or more custom terminology files referenced by name. Terminology files are uploaded as CSV or TMX and can be applied to any supported language pair.
{
"Text": "Configure the burst capacity for your API gateway.",
"SourceLanguageCode": "en",
"TargetLanguageCode": "ja",
"TerminologyNames": ["api-platform-terms", "product-names"]
}
Amazon allows stacking multiple terminology files, which is useful when you maintain separate glossaries for product names, UI strings, and technical vocabulary.
Azure Translator: Category and Custom Models
Azure's approach differs from the others. Rather than injecting a glossary at request time, Azure uses the category parameter to route requests to a custom-trained model that has been fine-tuned with your terminology through Custom Translator (https://learn.microsoft.com/en-us/azure/ai-services/translator/custom-translator/overview). Dynamic dictionary markup can also force specific translations inline using XML tags in the source text.
Provider glossary mechanics at a glance:
- DeepL: parameter glossary_id; scope per language pair; entry limits vary by plan.
- Google Cloud: parameter glossaryConfig; scope per glossary resource; quotas documented per project.
- Amazon Translate: parameter terminologyNames; stack multiple files; per-file limits apply.
- Azure Translator: category for custom models and inline dynamic dictionary tags; limits are model-dependent.
Choosing the right glossary mechanism depends on your language pair coverage, update frequency, and whether you need real-time glossary changes or can tolerate a training cycle. Ollang can transform a canonical TBX or CSV glossary into provider-specific formats at runtime to simplify multi-provider deployments.
Tag Handling: HTML, Markdown, and ICU Formats
Format preservation is where hybrid pipelines most commonly break. A single dropped </span> or reordered {placeholder} can crash a UI, corrupt a document, or produce gibberish for end users.
How MT APIs Handle Tags
Most MT APIs offer some form of tag-aware translation:
- DeepL supports tag_handling set to xml or html, with options to specify non_splitting_tags, splitting_tags, and ignore_tags.
- Google Cloud Translation accepts mimeType: "text/html" to preserve HTML structure.
- Amazon Translate processes HTML natively when the content type is set accordingly.
For ICU message format strings, none of the major MT APIs offer native support. The safest approach is to pre-process ICU patterns into tokenized segments (translating only the translatable text fragments), translate those fragments, and then reassemble the ICU structure.
Protected Segments
Some segments should never be translated: brand names, code identifiers, legal citations, URLs. Mark these as protected before sending to the MT engine. If the MT API supports ignore_tags or non-translatable spans, wrap protected content in those markers. Otherwise, replace protected content with numbered tokens during pre-processing and restore them afterward.
A protected-segment workflow:
1. Identify protected spans (regex + terminology database lookup).
2. Replace with tokens: Brand X → <x id="7"/>.
3. Send tokenized source to MT.
4. Validate that all tokens appear in the MT output.
5. Restore original content from the mapping table.
