-
Notifications
You must be signed in to change notification settings - Fork 26
Closed
Description
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?
deepl-java/deepl-java/src/main/java/com/deepl/api/Translator.java
Lines 920 to 936 in 9087e77
| * | |
| * @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
Labels
No labels