forked from Steven/DeepJ
changed "Translaotr.of()" to "Translator.newTranslator()"
This commit is contained in:
parent
aab9802e56
commit
e1017d8311
@ -35,10 +35,10 @@ public class Translator {
|
|||||||
public static void setGlobalAuthKey(String key) {
|
public static void setGlobalAuthKey(String key) {
|
||||||
globalAuthKey = key;
|
globalAuthKey = key;
|
||||||
}
|
}
|
||||||
public static Translator of(String authKey) {
|
public static Translator newTranslator(String authKey) {
|
||||||
return new Translator(authKey);
|
return new Translator(authKey);
|
||||||
}
|
}
|
||||||
public static Translator of() {
|
public static Translator newTranslator() {
|
||||||
if (globalAuthKey == null) {
|
if (globalAuthKey == null) {
|
||||||
System.out.println("\n[DeepJ] You are currently using the Global Auth Key \".of()\" Translator." +
|
System.out.println("\n[DeepJ] You are currently using the Global Auth Key \".of()\" Translator." +
|
||||||
"\n[DeepJ] If you are trying to use global auth keys, Call the method \"Translator.setGlobalAuthKey(String key)\" and then re-use this method." +
|
"\n[DeepJ] If you are trying to use global auth keys, Call the method \"Translator.setGlobalAuthKey(String key)\" and then re-use this method." +
|
||||||
@ -93,11 +93,8 @@ public class Translator {
|
|||||||
String encodedAuthKey = URLEncoder.encode(authKey, StandardCharsets.UTF_8);
|
String encodedAuthKey = URLEncoder.encode(authKey, StandardCharsets.UTF_8);
|
||||||
String encodedMessage = URLEncoder.encode(message, StandardCharsets.UTF_8);
|
String encodedMessage = URLEncoder.encode(message, StandardCharsets.UTF_8);
|
||||||
HttpClient client = HttpClient.newHttpClient();
|
HttpClient client = HttpClient.newHttpClient();
|
||||||
HttpRequest request = HttpRequest.newBuilder().GET()
|
HttpRequest request = HttpRequest.newBuilder().GET().header("Accept","*/*").header("Content-Type", "application/x-www-form-urlencoded").uri(URI.create("https://api-free.deepl.com/v2/translate?auth_key="+encodedAuthKey+"&target_lang="+langEnum.getApiString()+"&text="+encodedMessage)).build();
|
||||||
.header("Accept","*/*")
|
HttpResponse<String> response = client.send(request,HttpResponse.BodyHandlers.ofString());
|
||||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
|
||||||
.uri(URI.create("https://api-free.deepl.com/v2/translate?auth_key=" + encodedAuthKey + "&target_lang=" + langEnum.getApiString() + "&text=" + encodedMessage)).build();
|
|
||||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
|
||||||
return response.body();
|
return response.body();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user