---
title: "Machine-translate with a glossary and a · Agent Wranglers"
url: https://agentwranglers.se/playbook/localization/messages-and-translation/machine-translation-glossary
id: LOC-57
level: Recommended
updated: 2026-10-22
build: a2a6bdfed830
tokens: 888
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Machine-translate with a glossary and a do-not-translate list

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Messages and translation](https://agentwranglers.se/playbook/localization/messages-and-translation.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: LOC-57
- Level: Recommended
- Chapter: [Messages and translation](https://agentwranglers.se/playbook/localization/messages-and-translation.md)
- Rule: Give every machine translation engine a glossary per language and a list of terms it must never translate. A test checks each translated message against both.
- Check: A test reads every translated message. Each do-not-translate term in the source appears unchanged, each glossary term uses its listed translation, and every placeholder in the source is present.
- How: An engine that translates your product name, or picks a different word for "invoice" on each screen, makes one product read like several. Keep the glossary and the do-not-translate list in the repository or in the translation management system that holds the message files. Pass them to engines that accept them, as glossaries in the larger translation APIs do. Reuse approved translations from translation memory, so one source sentence never gets two translations. Placeholders and markup pass through unchanged. A fluent speaker still reviews the result, as [Give translators context and a review step](https://agentwranglers.se/playbook/localization/messages-and-translation/translator-context.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
for (const [key, source] of Object.entries(sourceMessages)) {
  const translated = messages.sv[key];
  for (const term of doNotTranslate) if (source.includes(term)) assert(translated.includes(term), `${key} lost ${term}`);
  for (const [term, sv] of Object.entries(glossary.sv)) if (source.includes(term)) assert(translated.includes(sv), `${key} must use ${sv}`);
}
```

### Python example

```python
import re
for key, source in source_messages.items():
    translated = messages["sv"][key]
    assert set(re.findall(r"\{\w+\}", source)) == set(re.findall(r"\{\w+\}", translated)), key
    for term in DO_NOT_TRANSLATE:
        if term in source:
            assert term in translated, f"{key} lost {term}"
```

## Sources

- [Google Cloud Translation: Create and use glossaries](https://cloud.google.com/translate/docs/advanced/glossary)

## Related rules

- LOC-21 [Give translators context and a review step](https://agentwranglers.se/playbook/localization/messages-and-translation/translator-context.md) in Localization

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/localization/messages-and-translation/machine-translation-glossary">Agent Wranglers localization playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Escape translated text like user input](https://agentwranglers.se/playbook/localization/messages-and-translation/escape-translations.md)
- [Messages and translation](https://agentwranglers.se/playbook/localization/messages-and-translation.md)
