Skip to content

Commit

Permalink
feat: auto translate
Browse files Browse the repository at this point in the history
  • Loading branch information
suuft committed Dec 21, 2022
1 parent 42f8949 commit 3a42bff
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
dependencies {
// other depends
implementation 'net.clojars.suuft:libretranslate-java:1.0.1'
implementation 'net.clojars.suuft:libretranslate-java:1.0.2'
}
```

Expand All @@ -38,7 +38,7 @@ Depend:
<dependency>
<groupId>net.clojars.suuft</groupId>
<artifactId>libretranslate-java</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
```
### `Usage:`
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'net.clojars.suuft'
version '1.0.1'
version '1.0.2'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/net/suuft/libretranslate/Translator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
import lombok.NonNull;
import lombok.Setter;
import lombok.experimental.UtilityClass;
import net.suuft.libretranslate.type.TranslateRequest;
import net.suuft.libretranslate.type.TranslateResponse;
import net.suuft.libretranslate.util.JsonUtil;

import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

@UtilityClass
Expand Down Expand Up @@ -52,6 +46,11 @@ public String translate(@NonNull String from, @NonNull String to, @NonNull Strin
e.printStackTrace();
return "Falled translate!";
}


}

public String translate(@NonNull String to, @NonNull String request){
return translate("auto", to, request);
}
}
16 changes: 0 additions & 16 deletions src/main/java/net/suuft/libretranslate/type/TranslateRequest.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/java/net/suuft/libretranslate/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public class Test {
public static void main(String[] args) {
Translator.setUrlApi("https://libretranslate.de/translate");
System.out.println(Translator.translate("ru", "en", "Для примера, переведем текст с русского на английский и выведем в консоль:"));
System.out.println(Translator.translate("auto", "en", "Для примера, переведем текст с русского на английский и выведем в консоль:"));
}
}

0 comments on commit 3a42bff

Please sign in to comment.