https://github.com/linus789/deepltranslator
The DeepL Translator is an API written in Java that translates via the DeepL website sentences. Without API key.
https://github.com/linus789/deepltranslator
deepl java selenium translator
Last synced: about 1 month ago
JSON representation
The DeepL Translator is an API written in Java that translates via the DeepL website sentences. Without API key.
- Host: GitHub
- URL: https://github.com/linus789/deepltranslator
- Owner: Linus789
- License: apache-2.0
- Created: 2018-03-30T22:18:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T22:56:40.000Z (almost 2 years ago)
- Last Synced: 2025-03-18T08:11:18.137Z (about 2 months ago)
- Topics: deepl, java, selenium, translator
- Language: Java
- Homepage:
- Size: 125 KB
- Stars: 57
- Watchers: 4
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeepLTranslator
> This project is a simple DeepL Translator API written in Java. It translates via the DeepL website sentences. This works without having a premium access and can be used free of charge.## Prerequisites
* ChromeDriver installed and located in [PATH](https://en.wikipedia.org/wiki/PATH_(variable))## Install
### Maven
Add the JitPack repository in your pom.xml
```xmljitpack.io
https://jitpack.io```
Add the dependency
```xmlcom.github.Linus789
DeepLTranslator
2.1.0```
### Gradle
Add the JitPack repository in your root build.gradle at the end of repositories
```kotlin
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
Add the dependency
```kotlin
dependencies {
implementation 'com.github.Linus789:DeepLTranslator:2.1.0'
}
```## Examples
### Using a configuration
```java
DeepLConfiguration deepLConfiguration = new DeepLConfiguration.Builder()
.setTimeout(Duration.ofSeconds(10))
.setRepetitions(3)
.setRepetitionsDelay(retryNumber -> Duration.ofMillis(3000 + 5000 * retryNumber))
.setPostProcessing(false)
.build();DeepLTranslator deepLTranslator = new DeepLTranslator(deepLConfiguration);
```### Synchronous translating
```java
try {
String translation = deepLTranslator.translate("I ran into a similar problem yesterday.", SourceLanguage.ENGLISH, TargetLanguage.GERMAN);
System.out.println(translation);
} catch (Exception e) {
e.printStackTrace();
}
```### Asynchronous translating
```java
deepLTranslator.translateAsync("Detected cow running backwards.", SourceLanguage.ENGLISH, TargetLanguage.GERMAN)
.whenComplete((res, ex) -> {
if (ex != null) {
ex.printStackTrace();
} else {
System.out.println(res);
}
});
```### Await termination
Blocks until all async translations from one `DeepLTranslator` instance have completed execution, or the timeout occurs,
or the current thread is interrupted, whichever happens first.
```java
try {
deepLTranslator.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
```### Shutdown
Stops all running threads
```java
DeepLTranslator.shutdown();
```### Example
* [DeepLTranslatorTest](src/test/java/DeepLTranslatorTest.java)## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details