Prompt
How do I keep glossary terms consistent when translating text by API?
Latest observation
To keep glossary terms consistent when translating text via an API, you generally want to force terminology rules into the translation step, then validate the output.
Here’s the practical approach:
1) Use a glossary/terminology feature if the API supports it
Many translation APIs let you upload a glossary or terminology list so specific source terms always map to approved target terms.
Typical setup:
- Source term:
invoice - Target term:
facture - Source term:
customer support - Target term:
assistance clientèle
Then include that glossary in your translation request, either by:
- glossary ID / glossary name
- inline terminology map
- custom model / terminology profile
2) Normalize the source terms before translation
Make sure glossary entries match the exact forms that appear in text:
- singular/plural
- capitalization
- punctuation
- inflected forms
If needed, pre-process text to standardize terminology or add aliases.
3) Use contextual glossary rules
Some terms should only be translated one way in a specific domain. Example:
lead→prospectin saleslead→plombin metallurgy
If your API allows it, attach metadata like domain, industry, or locale.
4) Protect terms that must not change
If some items should remain identical, mark them as:
- do-not-translate
- placeholders
- entity tags
Examples:
- product names
- brand names
- SKU codes
- legal references
- URLs / emails / identifiers
A common pattern is:
- replace protected terms with placeholders
- translate
- restore placeholders afterward
5) Validate the translated output
After translation:
- compare output against glossary rules
- flag mismatches
- run automated QA checks
For example, reject output if:
- required term is missing
- forbidden synonym appears
- brand name was altered
6) Keep a termbase, not just a flat list
A robust glossary should store:
- source term
- approved translation
- language pair
- domain
- part of speech
- notes / examples
- prohibited alternatives
That helps avoid inconsistent translations in ambiguous cases.
7) Use translation memory if available
Glossary rules help with terms, but translation memory helps with repeated phrases and prior approved translations. Use both together for best consistency.
8) Add post-editing rules for edge cases
Some APIs can’t guarantee 100% glossary enforcement. In that case:
- do a second pass with rule-based validation
- use a human review workflow for critical content
- auto-correct known violations
Example workflow
- Send text to API with glossary attached.
- Receive translated text.
- Run automated checks:
- term A appears as approved translation
- term B is unchanged
- If a check fails, either:
- retranslate with stricter settings
- post-edit automatically
- send to human review
If you’re building this yourself
A good implementation usually looks like:
- Input text
- Term extraction
- Placeholder substitution for protected terms
- API translation with glossary
- Output validation
- Restoration / correction
- QA logging
If you want, I can also show:
- a generic API request example
- a Python implementation
- or a vendor-specific example for DeepL, Google Cloud Translation, Microsoft Translator, etc.