Fixes an issue where Google Translate splits up the special tags that are used to replace URLs (leading to "__ u1__" in translated version), which means that the URL doesn't get put back in.

This commit is contained in:
PhotonQyv 2017-09-07 18:03:54 +01:00
parent 1cc9df1de1
commit 35d879e7e2
1 changed files with 11 additions and 1 deletions

View File

@ -975,7 +975,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
if (translator == Helper.TRANS_YANDEX)
aJsonString = yandexTranslateToText(translatedResult);
else if( translator == Helper.TRANS_GOOGLE)
aJsonString = shortnameToUnicode(googleTranslateToText(translatedResult), true);
aJsonString = googleTranslateToText(translatedResult);
if( aJsonString == null)
return;
Iterator itU = urlConversion.entrySet().iterator();
@ -1027,6 +1027,16 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
aJsonString = aJsonString.replace(" //","//");
aJsonString = aJsonString.replace(" www .","www.");
aJsonString = aJsonString.replace("www .","www.");
// This one might cause more trouble than it's worth
aJsonString = aJsonString.replaceAll("\\* \\.", "*.");
/*
Noticed that sometimes the special tags were getting messed up by Google,
might be other variants, only caught this one so far.
*/
aJsonString = aJsonString.replaceAll("__ (u|t)(\\d+)__", "__$1$2__");
aJsonString = URLDecoder.decode(aJsonString, "UTF-8");
return aJsonString;
}