When you translate at scale through APIs, raw machine translation output is rarely good enough. Terms get inconsistent, previously approved translations are ignored, and placeholders or HTML tags come back mangled. The result is broken UIs, off-brand messaging, and expensive post-editing cycles. Controlling this requires more than just sending strings to a translation endpoint, it demands structured use of glossaries, translation memories, and format-preservation directives at the API level. Ollang provides a single API execution layer that enforces glossaries, TM leverage, and format-preservation consistently across engines and providers.
This article walks through the practical mechanics: how to create and attach glossaries, import and leverage translation memories, preserve markup and placeholders, and validate that what comes back is safe to ship. If your team is ready to move beyond raw MT and enforce consistency programmatically, see how Ollang’s API layer centralizes terminology, TM, and format controls.
How Glossary APIs Enforce Terminology Consistency
Glossaries are the most direct way to ensure that specific terms, product names, legal phrases, brand vocabulary, translate the same way every time. Without them, even the best MT engine will produce variant translations for the same source term across requests. The fix is to manage glossaries as first-class API resources and attach them explicitly to every translation call.
Creating and Uploading Glossary Resources (TBX and CSV)
Most translation APIs support glossary creation through a dedicated endpoint. The typical workflow involves two steps: creating a glossary resource (specifying source and target languages), then uploading term entries in a supported format.
The two dominant formats are:
- TBX (TermBase eXchange): An ISO 30042 XML-based standard. TBX is ideal when glossaries need to carry metadata like term status, part of speech, or usage notes. It's widely supported by professional localization tools.
- CSV: A simpler tabular format, typically two columns (source term, target term) per language pair. CSV is easier to maintain in spreadsheets and faster to generate programmatically.
A typical glossary creation request might look like this:
curl -X POST https://api.provider.example/v2/glossaries \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "product-terms-en-de",
"source_lang": "en",
"target_lang": "de",
"entries_format": "csv",
"entries": "source,target\nDashboard,Dashboard\nWorkspace,Arbeitsbereich"
}'
The response returns a glossary_id that you store and reference in subsequent translation requests. For TBX uploads, the flow is similar but the body contains XML content or a file reference.
Key considerations when uploading:
- Validate entries before upload. Duplicate source terms with conflicting targets will produce unpredictable results.
- Keep glossaries scoped to a language pair. A single glossary covering en→de and en→fr creates ambiguity.
- Version your glossary files in source control alongside your code.
Attaching glossary_id to Translation Requests
Once a glossary exists, attach it to translation calls by including a glossary_id:
{
"text": ["Open the Dashboard and select your Workspace."],
"source_lang": "EN",
"target_lang": "DE",
"glossary_id": "gl-abc123"
}
This instructs the engine to enforce the glossary terms during translation. "Dashboard" stays as "Dashboard," and "Workspace" becomes "Arbeitsbereich" consistently.
A few rules to follow:
- Always validate that the glossary's language pair matches the request's language pair. Mismatches typically return a 400-level error, but some APIs silently ignore the glossary.
- If you manage multiple products or domains, maintain separate glossaries and select the right one per request based on content context.
- For batch translation jobs, attach the glossary at the job level rather than per-segment to reduce overhead and ensure consistency across the batch.
Leveraging Translation Memory Through APIs
While glossaries enforce term-level consistency, translation memories (TMs) operate at the segment level. A TM stores previously approved source-target pairs, full sentences or paragraphs, and reuses them when the same or similar source text appears again. This reduces cost, improves consistency, and accelerates turnaround.
TMX Import, Export, and Leverage Thresholds
TMX (Translation Memory eXchange) is the standard format for TM interchange. Most APIs that support TM functionality allow you to import TMX files to seed a memory and export them to back up or migrate approved translations.
A TMX import typically works as a bulk upload:
curl -X POST https://api.provider.example/v2/translation-memories/import \
-H "Authorization: Bearer $API_KEY" \
-F "file=@product-tm-en-fr.tmx" \
-F "name=product-tm-en-fr"
The critical configuration parameter is the leverage threshold, the minimum fuzzy match percentage at which a TM hit is used. Common settings:
- 100%: Only exact matches are reused. Safest option.
- 85-99%: Fuzzy matches are surfaced but may need review. Useful for reducing MT volume.
- 75-84%: Aggressive reuse. Higher risk of contextual mismatches.
- Below 75%: Generally not recommended, matches are too loose to be reliable.
Set the threshold based on your quality tolerance. For regulated content (legal, medical), stick to 100%. For marketing or support content where speed matters more, 85% is a practical floor.
When exporting TMX, pull regularly and archive. Your TM is a strategic asset, treat it like a database backup.
How TM Matches Reduce Cost and Improve Consistency
TM leverage directly reduces the volume of text sent to the MT engine or human translators. If 40% of your segments have exact TM matches, that's 40% less to translate and review.
Beyond cost, TMs enforce historical consistency. When a legal disclaimer was approved months ago, the TM ensures it comes back identical, not re-translated with different phrasing. This is especially important for:
- Software UI strings that users see repeatedly
- Compliance and regulatory text
- Standardized product descriptions
In API workflows, TM lookup typically happens before MT. The pipeline is: receive segment → query TM → if match above threshold, return TM result → otherwise, send to MT with glossary attached. Some APIs handle this internally; others expose it as a separate lookup endpoint you orchestrate yourself. If you need to centralize this logic across providers and avoid edge-case drift, evaluate a unified execution layer that applies TM-first routing consistently.
Preserving Placeholders, Tags, and Markup
Translations that break your application's rendering are worse than no translation at all. Placeholder corruption, missing HTML tags, and malformed ICU patterns cause crashes, layout failures, and data leaks. Format safety must be enforced at the API level, not patched after the fact.
Handling ICU, {placeholders}, and HTML Tags
Three categories of inline formatting demand attention:
- ICU MessageFormat patterns contain logic, plurals, selects, number formatting. A source string like {count, plural, one {# item} other {# items}} must preserve the ICU syntax exactly while translating only the human-readable parts.
- Simple placeholders like {username}, %s, or {{order_id}} represent runtime variables. They must pass through translation untouched and in the correct position.
- HTML tags such as <b>, <a href="...">, and <br/> control rendering. A missing closing tag or a translated attribute value breaks the page.
Most translation APIs offer a tag_handling or format parameter to address this:
{
"text": ["Hello <b>{username}</b>, you have <a href='/orders'>{count} orders</a>."],
"source_lang": "EN",
"target_lang": "JA",
"tag_handling": "html",
"preserve_formatting": true
}
When tag_handling is set to html, the engine parses the markup, translates only the text nodes, and reconstructs the tags around the translated content. For XML-based formats, a similar xml mode is typically available.
For ICU patterns, some APIs support an icu format mode. If your provider doesn't, pre-process the string: extract translatable segments, send them individually, and reassemble the pattern afterward. Never send raw ICU to an engine that doesn't understand it.
Do-Not-Translate Spans and Formality Controls
Not everything in a string should be translated. Brand names, code identifiers, and technical constants need to pass through unchanged. APIs handle this in several ways:
- Do-not-translate tags: Wrap protected content in a tag the engine recognizes, such as <notranslate>Ollang</notranslate> or provider-specific equivalents.
- Ignore patterns: Some APIs accept regex patterns that define what to skip.
- Glossary entries with identical source and target: Adding "Ollang" → "Ollang" in your glossary achieves the same effect.
Formality and domain controls are separate but related. Many APIs expose a formality parameter (formal, informal, default or vendor-specific values) that affects pronoun choice, verb conjugation, and register, critical for languages like German, Japanese, and Korean where formality changes the entire sentence structure.
{
"text": ["Please confirm your email address."],
"target_lang": "DE",
"formality": "more"
}
This produces "Bitte bestätigen Sie Ihre E-Mail-Adresse" (formal Sie) rather than the informal du form. Set formality at the project or content-type level and enforce it consistently across all API calls. If your team is juggling multiple providers with different approaches to format safety and formality, see how Ollang normalizes these controls across engines.
