Dev.to WebDev 🛠 Dev 👁 0 📖 4 min read

Treating Translation Memories as Code: A Technical Workflow for Managing TMX/TBX Assets

Most engineering teams building multilingual products treat localization as a content problem handled by "someone else." Then the day comes when you switch translation vendors, or bring localization in-house, and discove

Most engineering teams building multilingual products treat localization as a content problem handled by "someone else." Then the day comes when you switch translation vendors, or bring localization in-house, and discover that years of translated strings, context, and terminology decisions live locked inside a third-party CAT tool with no clean export path.

This is the same underlying issue described in this piece on translation memories and glossaries as corporate assets, but from a business/ownership angle. I want to cover the technical side: how to actually manage these assets as versioned, portable data instead of vendor lock-in, and how to wire them into your i18n pipeline.

TM and glossary data are just structured data

Strip away the terminology and you have two artifacts:

  • Translation Memory (TM): a set of aligned source/target segment pairs, usually with metadata (date, project, match quality). Standard interchange format is TMX (Translation Memory eXchange, XML-based).
  • Glossary / Termbase: a curated key-term list with approved translations per locale, often with part-of-speech, domain, and usage notes. Standard format is TBX (TermBase eXchange), though plenty of teams just use CSV/XLSX.

Both are portable, machine-readable, and version-controllable. There's no technical reason they should live exclusively inside a vendor's proprietary system.

A minimal pipeline for owning your linguistic assets

Here's a setup that works whether you're using a CAT tool, an LLM-based translation workflow, or both.

1. Treat your glossary as a config file, not a spreadsheet buried in Drive

{
  "term": "invoice",
  "domain": "finance",
  "translations": {
    "pt-PT": "fatura",
    "pt-BR": "nota fiscal",
    "es-ES": "factura",
    "fr-FR": "facture"
  },
  "do_not_translate": false,
  "notes": "pt-BR uses different legal term than pt-PT, not interchangeable"
}

Put this in a repo. Review changes via pull request, the same way you'd review a schema migration. Legal, product, and marketing can comment on the diff instead of emailing a spreadsheet around.

2. Export TMs in TMX and store them, don't let them live only in the vendor's cloud

Any competent CAT tool (memoQ, Trados, Phrase, Smartling) supports TMX export. Automate this:

# Pseudocode for a nightly TM export job
curl -X GET "https://api.vendor.com/v1/tm/export?format=tmx" \
  -H "Authorization: Bearer $VENDOR_API_KEY" \
  -o "tm_backup_$(date +%F).tmx"

aws s3 cp "tm_backup_$(date +%F).tmx" s3://your-bucket/translation-memories/

This single script solves the "vendor lock-in" problem the source article describes from a legal/ownership angle. If you own a daily TMX snapshot, switching suppliers costs you a re-import, not a rebuild.

3. Feed TM and glossary into your translation pipeline automatically

If you're using machine translation or LLMs as part of a hybrid workflow, the glossary should be injected into the prompt or the API call, not applied as a post-hoc find-and-replace.

import json

def build_translation_prompt(source_text, target_locale, glossary_path="glossary.json"):
    with open(glossary_path) as f:
        glossary = json.load(f)

    relevant_terms = [
        f"{entry['term']} -> {entry['translations'][target_locale]}"
        for entry in glossary
        if target_locale in entry['translations']
    ]

    prompt = f"""Translate the following text to {target_locale}.
Use these approved terms exactly as specified, do not deviate:
{chr(10).join(relevant_terms)}

Text:
{source_text}
"""
    return prompt

For API-based MT providers (DeepL, Google Cloud Translation, Azure Translator), check if they support glossary upload natively:

  • DeepL API supports glossaries via POST /v2/glossaries, scoped per language pair.
  • Google Cloud Translation supports glossaries as a resource you reference in translate requests.
  • Azure Translator supports "Custom Translator" with phrase dictionaries.

Using the native glossary feature is almost always better than prompt injection because it's deterministic, not probabilistic.

4. Validate TM matches before accepting them

Not all 100% matches are safe to reuse blindly, context can shift meaning. A lightweight validation step:

def is_safe_reuse(segment, tm_match, min_confidence=0.95):
    if tm_match['match_score'] < min_confidence:
        return False
    if tm_match['domain'] != segment.get('domain'):
        return False  # same string, different context, flag for review
    return True

This matters more than it sounds. A term like "charge" translates differently in a billing context versus a battery/hardware context. A naive 100%-match TM reuse will silently propagate the wrong one across your whole product.

Quality tiers, as a CI concept

The source article mentions defining quality tiers by document type: contracts need stricter review than internal reports. You can model this directly in your localization CI:

# l10n-config.yml
tiers:
  legal:
    tm_write: false        # don't pollute the core TM with ad hoc legal translations
    glossary_enforced: strict
    human_review: required
  marketing:
    tm_write: true
    glossary_enforced: moderate
    human_review: optional
  internal_docs:
    tm_write: false
    glossary_enforced: none
    human_review: none

Gate your pipeline on this config so low-rigor translations never get auto-merged into the assets that feed high-stakes documents.

Why this is worth the setup cost

Engineering teams are usually the ones who feel the pain first when linguistic assets are mismanaged: inconsistent strings across locales, repeated translation costs for identical UI copy, broken terminology after a vendor switch. The fix isn't exotic. It's the same discipline applied to any other data asset: standard formats, version control, automated export, and validation gates.

If you're setting this up for the first time, start small: export your current TM to TMX today, put your glossary in a JSON or YAML file in a repo, and automate the nightly backup. Everything else builds on that foundation.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.