forked from 5gi/DeepJ
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d5efc7b00 | |||
| 5d78663c87 | |||
| f47c69715c | |||
| 732fc3882d | |||
| 0e35a2f4c8 | |||
| c00f4b1a2d | |||
|
|
4c84fd5a98 | ||
| cc5a1b9df6 | |||
| 787664bb38 | |||
|
|
d1419d48e0 | ||
|
|
27cd9ec212 | ||
|
|
b96202a905 | ||
|
|
96c950ccfe | ||
|
|
9677f95d60 | ||
|
|
78c8146fed | ||
|
|
13155c9112 | ||
|
|
ff8b5ea1aa | ||
|
|
dd495dc277 | ||
|
|
31268450e7 | ||
| 04bfc0fe22 | |||
|
|
0b634901ff | ||
|
|
1b2f247a62 |
10
.idea/jarRepositories.xml
generated
10
.idea/jarRepositories.xml
generated
@@ -16,5 +16,15 @@
|
|||||||
<option name="name" value="MavenRepo" />
|
<option name="name" value="MavenRepo" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://git.nevets.tech/api/packages/5gi/maven" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
58
README.md
58
README.md
@@ -1,24 +1,56 @@
|
|||||||
# DeepJ
|
# DeepJ
|
||||||
█▀█ █▀█ █ █▀▀ █ █▄ █ ▄▀█ █
|
> Quick Setup
|
||||||
█▄█ █▀▄ █ █▄█ █ █ ▀█ █▀█ █▄▄
|
<details><summary>Gradle</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
█▄▄ █▄█
|
Go to your build.gradle file and type:
|
||||||
█▄█ █
|
|
||||||
|
|
||||||
█▀ ▀█▀ █▀▀ █ █ █▀▀ █▄ █
|
```
|
||||||
▄█ █ ██▄ ▀▄▀ ██▄ █ ▀█
|
repositories {
|
||||||
|
maven {
|
||||||
|
url "https://git.nevets.tech/api/packages/5gi/maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
and
|
||||||
|
|
||||||
________________________________________
|
```
|
||||||
|
dependencies {
|
||||||
|
implementation group: 'com.the5gi.deepj', name: 'DeepJ', version: 'VERSION'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
█ █ █▀█ █▀█ ▄▀█ ▀█▀ █▀▀ █▀█
|
<details><summary>Maven</summary>
|
||||||
█▄█ █▀▀ █▄█ █▀█ █ ██▄ █▄█
|
<p>
|
||||||
|
|
||||||
█▄▄ █▄█
|
Go to your pom.xml file and type:
|
||||||
█▄█ █
|
|
||||||
|
|
||||||
█▀ █▀▀ ▀█▀
|
```
|
||||||
▄█ █▄█ ▄█▄
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://git.nevets.tech/api/packages/5gi/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
```
|
||||||
|
and
|
||||||
|
```
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.the5gi.deepj</groupId>
|
||||||
|
<artifactId>DeepJ</artifactId>
|
||||||
|
<version>1.2.5</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
```
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
> Info
|
||||||
|
|
||||||
|
[To see more details, see the wiki](https://git.nevets.tech/5gi/DeepJ/wiki/Home#user-content-usage-setup).
|
||||||
________________________________________
|
________________________________________
|
||||||
|
|
||||||
DeepJ is a Java Wrapper for the DeepL Free Public API. This was originally made by Steven (Forked From) and Updated by 5gi
|
DeepJ is a Java Wrapper for the DeepL Free Public API. This was originally made by Steven (Forked From) and Updated by 5gi
|
||||||
26
build.gradle
26
build.gradle
@@ -3,38 +3,40 @@ plugins {
|
|||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'com.github.johnrengelman.shadow' version '5.2.0'
|
id 'com.github.johnrengelman.shadow' version '5.2.0'
|
||||||
}
|
}
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
group 'tech.nevets.deepj'
|
group 'com.the5gi.deepj'
|
||||||
version '1.1.0'
|
version '1.2.9'
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url "https://git.nevets.tech/api/packages/5gi/maven"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation group: 'org.json', name: 'json', version: '20210307'
|
implementation group: 'org.json', name: 'json', version: '20210307'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications{
|
publications{
|
||||||
publish(MavenPublication) {
|
publish(MavenPublication) {
|
||||||
artifact("target/DeepJ-$version" + "-all.jar") {
|
artifact("nexus/DeepJ-$version" + ".jar") {
|
||||||
extension 'jar'
|
extension 'jar'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name 'nexus'
|
name 'gitea'
|
||||||
url "https://repo.nevets.tech/repository/maven-releases/"
|
url "https://git.nevets.tech/api/packages/5gi/maven/"
|
||||||
credentials {
|
credentials.username System.getenv('fivegiUserGit')
|
||||||
username System.getenv('nexusUser')
|
credentials.password System.getenv('fivegiPassGit')
|
||||||
password System.getenv('nexusPass')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
package tech.nevets.DeepJ;
|
package com.the5gi.DeepJ;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -9,17 +10,19 @@ import java.net.http.HttpRequest;
|
|||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Translator {
|
public class Translator {
|
||||||
//TODO Test class to make sure multiple contructors work.
|
|
||||||
public static String globalAuthKey = "null";
|
public static String globalAuthKey = "null";
|
||||||
|
|
||||||
public static void setGlobalAuthKey(String key) {
|
public static void setGlobalAuthKey(String key) {
|
||||||
globalAuthKey = key;
|
globalAuthKey = key;
|
||||||
}
|
}
|
||||||
private Request request;
|
private Request request;
|
||||||
public Translator() {
|
public Translator() {
|
||||||
if (globalAuthKey == null) {
|
if (globalAuthKey == null) {
|
||||||
|
/*
|
||||||
|
[DeepJ] You are currently using the Global Auth Key Translator Constructor.
|
||||||
|
[DeepJ] If you are trying to use global auth keys, Call the method "Translator.setGlobalAuthKey(String key)" and then re-use this contructor.
|
||||||
|
[DeepJ] If you want to define a different authkey every time do: "new Translator(String authKey)"
|
||||||
|
*/
|
||||||
System.out.println("\n[DeepJ] You are currently using the Global Auth Key Translator Constructor." +
|
System.out.println("\n[DeepJ] You are currently using the Global Auth Key Translator Constructor." +
|
||||||
"\n[DeepJ] If you are trying to use global auth keys, Call the method \"Translator.setGlobalAuthKey(String key)\" and then re-use this contructor." +
|
"\n[DeepJ] If you are trying to use global auth keys, Call the method \"Translator.setGlobalAuthKey(String key)\" and then re-use this contructor." +
|
||||||
"\n[DeepJ] If you want to define an different authkey every time do: \"new Translator(String authKey)\"\n");
|
"\n[DeepJ] If you want to define an different authkey every time do: \"new Translator(String authKey)\"\n");
|
||||||
@@ -29,6 +32,10 @@ public class Translator {
|
|||||||
}
|
}
|
||||||
public Translator(String authKey) {
|
public Translator(String authKey) {
|
||||||
if (!Objects.equals(globalAuthKey, "null")) {
|
if (!Objects.equals(globalAuthKey, "null")) {
|
||||||
|
/*
|
||||||
|
[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing "new Traslator()"
|
||||||
|
instead of "new Translator(String authKey)". NOTE: This will work but just some advice :)
|
||||||
|
*/
|
||||||
System.out.println("[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing \"new Traslator()\"" +
|
System.out.println("[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing \"new Traslator()\"" +
|
||||||
"\n instead of \"new Translator(String authKey)\". NOTE: This will work but just some advice :)");
|
"\n instead of \"new Translator(String authKey)\". NOTE: This will work but just some advice :)");
|
||||||
}
|
}
|
||||||
@@ -36,12 +43,21 @@ public class Translator {
|
|||||||
}
|
}
|
||||||
public Translator(String authKey, boolean silence) {
|
public Translator(String authKey, boolean silence) {
|
||||||
if (!Objects.equals(globalAuthKey, "null") && !silence) {
|
if (!Objects.equals(globalAuthKey, "null") && !silence) {
|
||||||
|
/*
|
||||||
|
[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing "new Traslator()"
|
||||||
|
instead of "new Translator(String authKey)". NOTE: This will work but just some advice :)
|
||||||
|
*/
|
||||||
System.out.println("[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing \"new Traslator()\"" +
|
System.out.println("[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing \"new Traslator()\"" +
|
||||||
"\n instead of \"new Translator(String authKey)\". NOTE: This will work but this is just some advice :)");
|
"\n instead of \"new Translator(String authKey)\". NOTE: This will work but this is just some advice :)");
|
||||||
}
|
}
|
||||||
request = new Request(authKey);
|
request = new Request(authKey);
|
||||||
}
|
}
|
||||||
|
public void setAPIKey(String authKey) {
|
||||||
|
request = new Request(authKey);
|
||||||
|
}
|
||||||
|
public String getAPIKey() {
|
||||||
|
return request.authKey;
|
||||||
|
}
|
||||||
public String translate(Language langToTranslateTo, String sourceMessage) {
|
public String translate(Language langToTranslateTo, String sourceMessage) {
|
||||||
String response = "Error processing request";
|
String response = "Error processing request";
|
||||||
try {
|
try {
|
||||||
@@ -60,7 +76,7 @@ public class Translator {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
protected static class Request {
|
protected static class Request {
|
||||||
private final String authKey;
|
public final String authKey;
|
||||||
public Request(String authKey) {
|
public Request(String authKey) {
|
||||||
this.authKey = authKey;
|
this.authKey = authKey;
|
||||||
}
|
}
|
||||||
@@ -76,7 +92,6 @@ public class Translator {
|
|||||||
return response.body();
|
return response.body();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Language {
|
public enum Language {
|
||||||
Bulgarian("BG"),
|
Bulgarian("BG"),
|
||||||
Czech("CS"),
|
Czech("CS"),
|
||||||
Reference in New Issue
Block a user