Context parameter examples

Some practical examples for getting the most out of the context parameter

When short content like headlines, product titles or titles are translated with DeepL, there may not be enough information for the translation engine to work with to fully understand the wider context. This might be noticeable when the source content could have multiple meanings and requires additional context in order to provide the best possible translation.

With the introduction of the context parameter, you can now provide additional context for shorter pieces of source content without incurring additional translation usage.

Consider the German sentence “Die Person stand vor dem Tor”, translated into US English in the following example:

curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [your key]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "Die Person stand vor dem Tor."
  ],
  "target_lang": "EN-US"
}'
// "The person was standing in front of the gate."

Without any additional context, the returned translation is “The person was standing in front of the gate”. This might be correct, but what if we were at a football game?

By providing additional context, we can help the DeepL find the correct translation:

curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [your key]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "Die Person stand vor dem Tor."
  ],
  "target_lang": "EN-US",
  "context": "Dies ist ein Text über Fußball."
}'
//"The person was standing in front of the goal."

In another example, the correct grammatical gender to use in a translation may not be totally clear from source content. Below, the English sentence “The teacher asked the class to tidy up after they finished the lesson.” makes syntactical sense, however it does not provide clarity on which variant of the word “teacher” to use when translated. Without context the translation into German is “Lehrer”:

curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [your key]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "The teacher asked the class to tidy up after they finished the lesson."
  ],
  "target_lang": "DE"
}'
//"Der Lehrer bat die Klasse, nach der Stunde aufzuräumen."

By providing more context describing the teacher, we can help DeepL get to a more accurate translation, without adding more to the source content:

curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [your key]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "The teacher asked the class to tidy up after they finished the lesson."
  ],
  "target_lang": "DE",
  "context": "She did not want to use her own time tidying up."
}'
//"Die Lehrerin bat die Klasse, nach der Stunde aufzuräumen."

As you can see, even with a little additional information provided by the context parameter (in the same style as the text being translated), the overall translation accuracy is improved - including grammar and syntax.

Learn more about using the context parameter in the text translation API reference.

Last updated