Skip to content

Deepl client does not allow 'en' and 'pt' target languages #63

@frq-asgard-toge

Description

@frq-asgard-toge

The documentation states that it is possible to use 'en' as a valid target language, just as being able to use pt and zh.
The API supports this as well and will translate content just fine.

So why does the Java Client have specific checks that throw an exception when you are trying to use them?

*
* @param sourceLang Language code of the input language, or <code>null</code> to use
* auto-detection.
* @param targetLang Language code of the desired output language.
* @throws IllegalArgumentException If either language code is invalid.
*/
protected static void checkValidLanguages(@Nullable String sourceLang, String targetLang)
throws IllegalArgumentException {
if (sourceLang != null && sourceLang.isEmpty()) {
throw new IllegalArgumentException("sourceLang must be null or non-empty");
}
if (targetLang.isEmpty()) {
throw new IllegalArgumentException("targetLang must not be empty");
}
switch (targetLang) {
case "en":
throw new IllegalArgumentException(

You can reproduce that the regular 'en' tag works with the API via the following cURL command:
curl -v -XPOST -H 'Authorization: DeepL-Auth-Key my-deepl-key' -H "Content-type: application/json" -d '{"source_language": "DE", "text":["Hallo große Welt da draußen"],"target_lang":"EN"}' 'https://api.deepl.com/v2/translate'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions