mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 00:30:03 +02:00
working
This commit is contained in:
parent
4eb4c6eea5
commit
4b8563fe7e
6 changed files with 30 additions and 3 deletions
|
@ -63,7 +63,11 @@ public class TranslateHelper {
|
|||
if (translator.compareToIgnoreCase("FEDILAB") == 0) {
|
||||
myTransL.setLibretranslateDomain("translate.fedilab.app");
|
||||
} else if (translator.compareToIgnoreCase("LINGVA") == 0) {
|
||||
myTransL.setLibretranslateDomain("lingva.ml");
|
||||
String host = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_DOMAIN), context.getString(R.string.SET_TRANSLATOR_HOST_LINGVA));
|
||||
if (host == null || host.trim().isEmpty()) {
|
||||
host = context.getString(R.string.SET_TRANSLATOR_HOST_LINGVA);
|
||||
}
|
||||
myTransL.setLingvaDomain(host);
|
||||
} else {
|
||||
String translatorVersion = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_VERSION), "PRO");
|
||||
params.setPro(translatorVersion.equals("PRO"));
|
||||
|
|
|
@ -47,7 +47,8 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
ListPreference SET_TRANSLATOR_VERSION = findPreference(getString(R.string.SET_TRANSLATOR_VERSION));
|
||||
|
||||
EditTextPreference SET_TRANSLATOR_API_KEY = findPreference(getString(R.string.SET_TRANSLATOR_API_KEY));
|
||||
if (SET_TRANSLATOR != null && SET_TRANSLATOR.getValue().equals("FEDILAB")) {
|
||||
EditTextPreference SET_TRANSLATOR_DOMAIN = findPreference(getString(R.string.SET_TRANSLATOR_DOMAIN));
|
||||
if (SET_TRANSLATOR != null && !SET_TRANSLATOR.getValue().equals("DEEPL")) {
|
||||
if (SET_TRANSLATOR_API_KEY != null) {
|
||||
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_API_KEY");
|
||||
}
|
||||
|
@ -55,6 +56,11 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_VERSION");
|
||||
}
|
||||
}
|
||||
if (SET_TRANSLATOR != null && !SET_TRANSLATOR.getValue().equals("LINGVA")) {
|
||||
if (SET_TRANSLATOR_DOMAIN != null) {
|
||||
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_DOMAIN");
|
||||
}
|
||||
}
|
||||
SwitchPreferenceCompat SET_DISPLAY_BOOKMARK = findPreference(getString(R.string.SET_DISPLAY_BOOKMARK));
|
||||
if (SET_DISPLAY_BOOKMARK != null) {
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||
|
|
4
app/src/main/res/layouts/mastodon/values/strings.xml
Normal file
4
app/src/main/res/layouts/mastodon/values/strings.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="translator_domain">Translator domain</string>
|
||||
</resources>
|
|
@ -796,6 +796,7 @@
|
|||
|
||||
<string-array name="set_translator_values" translatable="false">
|
||||
<item>Fedilab</item>
|
||||
<item>Lingva</item>
|
||||
<item>DeepL</item>
|
||||
</string-array>
|
||||
<string-array name="set_translator_version_values">
|
||||
|
@ -805,6 +806,7 @@
|
|||
|
||||
<string-array name="SET_TRANSLATOR_VALUES" translatable="false">
|
||||
<item>FEDILAB</item>
|
||||
<item>LINGVA</item>
|
||||
<item>DEEPL</item>
|
||||
</string-array>
|
||||
|
||||
|
@ -1097,6 +1099,8 @@
|
|||
<string name="SET_POST_FORMAT" translatable="false">SET_POST_FORMAT</string>
|
||||
<string name="SET_COMPOSE_LOCAL_ONLY" translatable="false">SET_COMPOSE_LOCAL_ONLY</string>
|
||||
|
||||
<string name="SET_TRANSLATOR_HOST_LINGVA" translatable="false">lingva.ml</string>
|
||||
<string name="SET_TRANSLATOR_DOMAIN" translatable="false">SET_TRANSLATOR_DOMAIN</string>
|
||||
<string name="SET_TRANSLATOR" translatable="false">SET_TRANSLATOR</string>
|
||||
<string name="SET_TRANSLATOR_VERSION" translatable="false">SET_TRANSLATOR_VERSION</string>
|
||||
|
||||
|
|
|
@ -93,6 +93,13 @@
|
|||
app:key="@string/SET_TRANSLATOR_API_KEY"
|
||||
app:title="@string/api_key"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<EditTextPreference
|
||||
app:defaultValue="lingva.ml"
|
||||
app:dependency="@string/SET_TRANSLATOR"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_TRANSLATOR_DOMAIN"
|
||||
app:title="@string/translator_domain"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
app:defaultValue="PRO"
|
||||
app:dialogTitle="@string/version"
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.json.JSONException;
|
|||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
|
@ -148,7 +149,8 @@ public class TransAsync {
|
|||
str_response = new Client().post(MyTransL.getLibreTranslateUrl(), this.timeout, params);
|
||||
} else if (te == MyTransL.translatorEngine.LINGVA) {
|
||||
String key = MyTransL.getInstance(te).getLibreTranslateAPIKey();
|
||||
String lingvaURL = MyTransL.getLingvaUrl() + this.params.getSource_lang() + "/" + toLanguage + "/" + contentToSend;
|
||||
String contentToSendEncoded = URLEncoder.encode(contentToSend, "UTF-8");
|
||||
String lingvaURL = MyTransL.getLingvaUrl() + this.params.getSource_lang() + "/" + toLanguage + "/" + contentToSendEncoded;
|
||||
str_response = new Client().get(lingvaURL, this.timeout);
|
||||
}
|
||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException err) {
|
||||
|
|
Loading…
Reference in a new issue