How DeepL translation works in the engine
When translation by DeepL is enabled in the engine, text translation requests are submitted to DeepL if all languages (source and target) are considered to be supported by DeepL. If this is not the case, the request will be submitted to the EVP.
The information below concerns version 1 of the DeepL translation integration (Release 2024.2).
Note that switching to EVP necessarily excludes use of the glossary, since this is a feature specific to DeepL.
Reminder: general coding of languages (ISO)
A language is designated by an ISO 639 language code. There are different forms of ISO code: 639-1 (also known as alpha-2, because it's a 2-letter code), 639-2 and 639-3.
A language code can be associated with a country variant, corresponding to the ISO 3166 standard, also available in 3166-1 (alpha-2), 3166-2, etc. The country code follows the language code, separated by a hyphen or an underscore, depending on the system.
For example,
the ISO 639-1 (alpha-2) language code for French is fr
fr-FR is the code for the French language spoken in France (a combination of the language code fr and the country code FR).
fr-CA is the code for the French language spoken in Canada (a combination of the fr language code and the CA country code).
en-GB is the code for the English language spoken in Great Britain
en-US is the code for the English language spoken in the USA
How translation works DeepL
DeepL supports a number of languages for translation :
some with an ISO-639-1 (alpha 2) language code
some with a language code that varies by country (ISO-639-1 (alpha2) followed by ISO-3166-1 (alpha 2))
the source languages (the language of the text to be translated) currently supported are all variant-free languages
target languages (those into which to translate) are mostly ISO-639-1 language codes, with the exception of
en-GB for British English
en-US for American English
pt-BR for Brazilian Portuguese
pt-PT for non-Brazilian Portuguese
Please note that DeepL does not support translation into English (code en) or Portuguese (pt). The variant is mandatory when specifying an English or Portuguese target language.
Note also that when it comes to glossaries, only the language is supported, even when translating into a language with a variant. For example, the glossary used for a translation from fr to en-GB translation will be the fr to en glossary.
A list of supported languages can be found at URL https://club-wed.wedia-group.com/_plugins/WXM_DEEPL/page/admin/supportedLanguages.jspz :
How translation requests are sent to DeepL
When a translation request is sent to DeepL, the language codes are converted according to these rules:
in all cases, case is converted to conform to DeepL (upper case). Case is therefore of no importance in codes passed as parameters.
in all cases, the hyphen and underscore are considered as separating characters for language and country codes. Either character can therefore be used in the codes passed as parameters.
for source languages,
we always take only the language (ignoring the country variant if present). For example, if the source language specified in the parameters is fr_CA, we'll assume that the source language of the text to be translated is FR (French)
for target languages
in the case of a language DeepL without a variant such as FR (French), only the language is considered. For example, if we request a translation into fr_BE (French from Belgium), we'll send DeepL a request for translation into FR.
when the language is DeepL with variant
if the variant is supported by DeepL, we keep it. For example, if you ask for a translation to en_GB, you will ask DeepL for a translation to EN-GB.
if the variant is not supported by DeepL, we arbitrarily choose a supported variant instead:
US variant for the EN language code (for example, if you request an en_CA translation, you'll send DeepL a request for an EN-US translation).
variant PT for language code PT.
alpha-3 code support: if alpha-3 code is natively convertible by Java to alpha-2, then this code will be converted to DeepL code.
Test language support before sending to DeepL
Before sending a request to DeepL, we test the source and target languages specified in the translation request parameters.
If one of the languages is not considered supported, we switch to EVP.
Strict mode test
In strict mode, we check whether the code indicated in the parameters is supported by DeepL (case-sensitive and separator-compatible).
With an exception for English:
the EN code is always considered to be supported as a target language (whereas it is not by DeepL as a target language)
EN code with country variants is always considered to be supported as a source language, so that en_GB, en_US or en_CA texts can be translated in strict mode as EN texts, even though DeepL does not support these languages as a source language.
the ENG code is not considered EN
For example, if you request the translation of a text in fr_CA (Canadian French) into en_US, you'll have to switch to EVP, because DeepL doesn't support fr_CA as a source language.
Flexible mode testing
In flexible mode, we first convert a code indicated in the parameters to a DeepL code (as indicated above) and if this code is well supported by DeepL, we send the request to DeepL (otherwise we switch to EVP).
For example, if the source language code is fr_CA, we convert it to FR. This code is supported by DeepL, so the translation request will be sent to DeepL (provided that the target language codes are also supported by DeepL).
But beware: if you request a translation in zh_SG (Singapore Chinese), the text will be translated into zh (i.e. simplified Chinese), as this is the only Chinese supported by DeepL.
Choice between flexible and strict modes
To know whether to choose between flexible and strict modes, you need to ask yourself whether you want to have a differentiated translation across the country.
For example, if the customer insists that a translation to fr_CA is not a translation to FR, or in particular, if the customer insists on a differentiated translation between Chinese from China (zh_CN) and Chinese from Singapore (zh_SG), use the strict mode (which will cause a switch to EVP, since none of these languages are supported by DeepL).
If a translation into a language can be made into the translation in the language without country variation, you can choose flexible mode. For example, a translation request to fr_CA will be a translation DeepL to FR in flexible mode, whereas it will switch to EVP in strict mode.