changed "Translaotr.of()" to "Translator.newTranslator()"

This commit is contained in:
5gi 2022-11-18 12:41:11 -05:00
parent aab9802e56
commit e1017d8311

View File

@ -35,10 +35,10 @@ public class Translator {
public static void setGlobalAuthKey(String key) {
globalAuthKey = key;
}
public static Translator of(String authKey) {
public static Translator newTranslator(String authKey) {
return new Translator(authKey);
}
public static Translator of() {
public static Translator newTranslator() {
if (globalAuthKey == null) {
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." +
@ -93,11 +93,8 @@ public class Translator {
String encodedAuthKey = URLEncoder.encode(authKey, StandardCharsets.UTF_8);
String encodedMessage = URLEncoder.encode(message, StandardCharsets.UTF_8);
HttpClient client = HttpClient.newHttpClient();
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();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
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();
HttpResponse<String> response = client.send(request,HttpResponse.BodyHandlers.ofString());
return response.body();
}
}
@ -136,4 +133,4 @@ public class Translator {
return this.apiString;
}
}
}
}