1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 18:27:43 +00:00

Added LT preferred variants

This commit is contained in:
M66B 2022-04-27 21:04:10 +02:00
parent 6aa93c3c84
commit b810b02697

View file

@ -33,6 +33,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
@ -44,7 +45,9 @@ public class LanguageTool {
// https://languagetool.org/http-api/swagger-ui/#!/default/post_check // https://languagetool.org/http-api/swagger-ui/#!/default/post_check
String request = String request =
"text=" + URLEncoder.encode(text.toString(), StandardCharsets.UTF_8.name()) + "text=" + URLEncoder.encode(text.toString(), StandardCharsets.UTF_8.name()) +
"&language=auto"; "&language=auto" +
"&preferredVariants=" + Locale.getDefault().toLanguageTag();
Log.i("LT request=" + request);
URL url = new URL(LT_URI + "check"); URL url = new URL(LT_URI + "check");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
@ -75,6 +78,7 @@ public class LanguageTool {
} }
String response = Helper.readStream(connection.getInputStream()); String response = Helper.readStream(connection.getInputStream());
Log.i("LT response=" + response);
List<Suggestion> result = new ArrayList<>(); List<Suggestion> result = new ArrayList<>();