fixed gtranslate + added reply’s translate
This commit is contained in:
@@ -101,10 +101,22 @@ public class DNRInjector {
|
||||
|
||||
public static boolean onClickMsg(Context context, MsgAction action, Msg msg) {
|
||||
var text = ((MsgFromUser) msg).f();
|
||||
var fullMsg = ((MsgFromUser) msg).j2(); // text + reply
|
||||
var reply = fullMsg.substring(text.length() + 1);
|
||||
|
||||
var isTextExist = !text.isEmpty() && !text.equals(" ");
|
||||
var isReplyExist = !reply.isEmpty() && !reply.equals(" ");
|
||||
|
||||
if (action == MsgAction.valueOf("TRANSLATE")) {
|
||||
if (text.isEmpty() || text.equals(" ")) sendToast("Невозможно перевести этот текст");
|
||||
else Translate.showTranslatedText(context, text);
|
||||
if (isTextExist && isReplyExist) {
|
||||
Translate.showTranslatedText(context, text + "\n\nРеплай:\n" + reply);
|
||||
} else if (isReplyExist) {
|
||||
Translate.showTranslatedText(context, "Реплай:\n" + reply);
|
||||
} else if (isTextExist) {
|
||||
Translate.showTranslatedText(context, text);
|
||||
} else {
|
||||
sendToast("Нет текста для перевода");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class GoogleTranslator extends BaseTranslator {
|
||||
.b("https://translate.googleapis.com/translate_a/single?dj=1" +
|
||||
"&q=" + URLEncoder.encode(text, "UTF-8") +
|
||||
"&sl=auto" +
|
||||
"&tl=" + Locale.getDefault().getLanguage() +
|
||||
"&tl=" + getToLanguage() +
|
||||
"&ie=UTF-8&oe=UTF-8&client=at&dt=t&otf=2")
|
||||
.a("User-Agent",
|
||||
"GoogleTranslate/6.28.0.05.421483610 (" + devices[(int) Math.round(Math.random() * (devices.length - 1))] + ")")
|
||||
|
||||
Reference in New Issue
Block a user