Skip to main content

Glossary Support

Glossaries let you enforce consistent terminology in your translations. Pass an array of source→target term mappings, and Langbly will use those exact translations whenever the terms appear.

Use Cases

  • Brand names: "Acme Portal" should always stay "Acme Portal" (or translate to a specific localized name)
  • Product terms: "Dashboard" → "Overzichtspagina" (instead of generic "Dashboard")
  • Industry jargon: "Sprint" → "Sprint" (keep Agile terminology untranslated)
  • Legal terms: Ensure consistent legal terminology across documents

Request Format

Add a glossary array to your translation request body:

{
"q": "Navigate to the Dashboard and check your Sprint progress.",
"target": "nl",
"glossary": [
{ "source": "Dashboard", "target": "Overzichtspagina" },
{ "source": "Sprint", "target": "Sprint" }
]
}

Response

{
"data": {
"translations": [
{
"translatedText": "Navigeer naar de Overzichtspagina en bekijk je Sprint-voortgang."
}
]
}
}

Without the glossary, "Dashboard" might be translated as "Dashboard" (kept as-is) or "Controlepaneel", and the result would be inconsistent.

Glossary Entry Format

Each entry in the glossary array must have:

FieldTypeRequiredDescription
sourcestringYesThe term in the source language
targetstringYesThe required translation for this term

Examples

Python SDK

from langbly import Langbly

client = Langbly(api_key="your-key")

result = client.translate(
q="Check your Dashboard for Sprint updates.",
target="nl",
glossary=[
{"source": "Dashboard", "target": "Overzichtspagina"},
{"source": "Sprint", "target": "Sprint"},
]
)

Node.js SDK

import { Langbly } from 'langbly';

const client = new Langbly({ apiKey: 'your-key' });

const result = await client.translate({
q: 'Check your Dashboard for Sprint updates.',
target: 'nl',
glossary: [
{ source: 'Dashboard', target: 'Overzichtspagina' },
{ source: 'Sprint', target: 'Sprint' },
],
});

cURL

curl -X POST https://api.langbly.com/language/translate/v2 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "Check your Dashboard for Sprint updates.",
"target": "nl",
"glossary": [
{"source": "Dashboard", "target": "Overzichtspagina"},
{"source": "Sprint", "target": "Sprint"}
]
}'

Limits

  • Maximum 200 glossary entries per request
  • Entries are applied per-request (not stored server-side)
  • Empty source or target values are silently ignored

Caching

Glossary affects the cache key. Two requests with the same text but different glossaries will produce separate cache entries. Requests without a glossary still use the regular cache.

Tips

  • Case sensitivity: Glossary matching is case-sensitive. Include both "dashboard" and "Dashboard" if you need both matched.
  • Phrases: You can use multi-word phrases, not just single terms.
  • Keep it short: The glossary is injected into the translation prompt. Excessive entries may slightly increase latency.
  • Brand names: Use glossary to ensure brand names are never translated or always translated consistently.

Difference from Google Translate Glossary

Google Translate requires you to create and manage glossary resources via a separate API. Langbly's glossary is per-request, so no resource management is needed. Just pass the terms with each request.

FeatureGoogle TranslateLangbly
SetupCreate glossary resource firstPer-request, no setup
ManagementSeparate API for CRUDNone needed
Max entries10,000 per resource200 per request
StorageServer-sideStateless
CostExtra API callsIncluded