Skip to main content

About translation memories

Translation memories store and reuse previously created translations. When you translate with a translation memory, your source text is compared against the translation memory’s segments. If a segment is similar enough, the stored translation is applied instead of generating a new one.

What you’ll learn

In this tutorial, we’ll retrieve the translation memories on your account, use one in a translation request, adjust the matching threshold to control how closely source text must match a stored segment, and see which parts of a translation came from the translation memory.

Before you begin

You’ll need:
  • A DeepL API authentication key
  • At least one translation memory uploaded to your account via the DeepL UI
  • A terminal or HTTP client for making API requests
  • Approximately 10 minutes

Example translation memory

In this tutorial, we’ll use a translation memory called “Greetings” that contains German-to-English translations. One of its segments looks like this: Notice that the translation memory specifies a custom translation — “Hello everyone!” instead of the literal “Hello world!”. When we send matching source text to the API with this translation memory, DeepL will reuse the stored translation instead of generating its own.

Step 1: List your translation memories

First, let’s retrieve the translation memories on your account so we can find the one we want to use.
Expected output:
Notice the translation_memory_id — this is what we’ll pass to the translate endpoint. Also note the source_language and target_languages fields, which tell us this translation memory translates from German to English.
If you see an empty list, make sure you’ve uploaded at least one translation memory via the DeepL translation memory page.

Step 2: Translate text with a translation memory

Now let’s use that translation memory in a translation request. Add the translation_memory_id parameter to your call to the text translation endpoint.
Expected output:
The result is “Hello everyone!” — the custom translation from our translation memory — rather than the default “Hello world!” that DeepL would produce without it. Notice that we didn’t need to specify source_lang — language auto-detection still works when using a translation memory.

Step 3: Adjust the matching threshold

By default, a stored segment is applied when it matches at least 75% of the source text. This means translation memory segments can match even when the source text isn’t identical — which is useful for catching typos and minor variations. The lowest supported threshold is 50, and a lower value is treated as 50. Let’s see this in action. Imagine we make a typo and send “Halloo Welt!” instead of “Hallo Welt!”:
Expected output:
With the default threshold of 75, “Halloo Welt!” is close enough to “Hallo Welt!” that the translation memory segment still applies, and we get our custom translation “Hello everyone!”. Now let’s raise the threshold to 100 so only exact matches are used:
Expected output:
With a threshold of 100, “Halloo Welt!” is no longer an exact match for “Hallo Welt!”, so the translation memory segment is not applied. DeepL falls back to its default translation: “Hello world!”.

Step 4: See which segments came from the translation memory

Finally, let’s find out which parts of a translation came from the translation memory, for example so that only freshly translated text goes to human review. We’ll send a text with two sentences, only the first of which is stored, and set show_translation_memory_matches to true.
Expected output:
Each entry names the stored segment that was used, its match score, and the text_ranges it covers in text, counted in Unicode code points. Here, “Hello everyone!” (code points 0 up to, but not including, 15) came from the translation memory, while “How are you?” was freshly translated. An empty translation_memory_matches list means nothing from the translation memory reached the output. Two things to notice about ranges:
  • end is exclusive, so a range covers text[start:end]
  • A range that does not start the text includes the whitespace before the segment. Trim it if you display or compare the ranged text.
For the full behavior, including fuzzy matches, tag handling, and style profiles, see the show_translation_memory_matches parameter reference.

What you’ve accomplished

You’ve learned how to:
  • Retrieve the translation memories on your account
  • Use a translation memory in a translation request
  • Control the matching threshold to tune how closely source text must match a stored segment
  • Find out which segments of a translation came from the translation memory

See also