diff options
author | Thomas <tschneider.ac@gmail.com> | 2022-12-27 16:50:08 +0100 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2022-12-27 16:50:08 +0100 |
commit | 4be595ea54425ebf08ca6538827e08cf4cdc6b58 (patch) | |
tree | 471634dcab75b827f92a9c5b07068921d5a05ccf /mytransl | |
parent | b9eca58ccb409ba3c84746d09ab67907507a0701 (diff) |
Add deepl support
Diffstat (limited to 'mytransl')
-rw-r--r-- | mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java | 10 | ||||
-rw-r--r-- | mytransl/src/main/java/com/github/stom79/mytransl/translate/Params.java | 10 |
2 files changed, 17 insertions, 3 deletions
diff --git a/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java b/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java index 86aaac0f6..2b27c86b9 100644 --- a/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java +++ b/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java @@ -28,7 +28,8 @@ public class Helper { private static final String YANDEX_BASE_URL = "https://translate.yandex.net/api/v1.5/tr.json/translate?"; - private static final String DEEPL_BASE_URL = "https://api.deepl.com/v1/translate?"; + private static final String DEEPL_BASE_URL = "https://free.deepl.com/v2/translate?"; + private static final String DEEPL_BASE_FREE_URL = "https://api-free.deepl.com/v2/translate?"; private static final String SYSTRAN_BASE_URL = "https://api-platform.systran.net/translation/text/translate?"; private static final String[] deeplAvailableLang = {"EN", "DE", "FR", "ES", "IT", "NL", "PL"}; @@ -98,8 +99,11 @@ public class Helper { if (deepLParams.getNon_splitting_tags() != null) params += "&tag_handling=" + deepLParams.getNon_splitting_tags(); - - return Helper.DEEPL_BASE_URL + text + lang + params + key; + if (deepLParams.isPro()) { + return Helper.DEEPL_BASE_URL + text + lang + params + key; + } else { + return Helper.DEEPL_BASE_FREE_URL + text + lang + params + key; + } } diff --git a/mytransl/src/main/java/com/github/stom79/mytransl/translate/Params.java b/mytransl/src/main/java/com/github/stom79/mytransl/translate/Params.java index fba8eec63..a49c85613 100644 --- a/mytransl/src/main/java/com/github/stom79/mytransl/translate/Params.java +++ b/mytransl/src/main/java/com/github/stom79/mytransl/translate/Params.java @@ -25,6 +25,7 @@ public class Params { private String ignore_tags; private boolean split_sentences = true; private boolean preserve_formatting = false; + private boolean isPro = true; private Params.fType format; public Params.fType getFormat() { @@ -86,6 +87,15 @@ public class Params { this.preserve_formatting = preserve_formatting; } + + public boolean isPro() { + return isPro; + } + + public void setPro(boolean pro) { + this.isPro = pro; + } + public enum fType { @SerializedName("TEXT") TEXT("text"), |