It's an ago old thread, but assuming it's the same macro that's included out-of-box long since, it meanwhile needs 2 little bugfixes for "Selected" text. Can only test in KM1.6, but in KM76 those snippets still seem to be the same in included translate.kmm, so most likely needed there too.
@Dorian
==> The blank insertion after linebreaks is very simple and necessary, please include by default.
Am only not entirely sure if the length-limit is the same for all KM-versions and win-systems, perhaps someone can test?
Around line 70 replace this:
_Translate_text{
$OpenURL=sub("<txt>",urlencode($OpenURL),gsub("<from>",$_from,gsub("<to>",$_to,getpref(STRING,$_Translate_pref_text)))); &OpenURL_Selected;
}
with something like this:
_Translate_text{
$OpenURL=sub("<txt>",urlencode($OpenURL),gsub("<from>",$_from,gsub("<to>",$_to,getpref(STRING,$_Translate_pref_text))));
# fix bug: linebreaks without blank merge together last+1.st word on selection-translation:
$OpenURL=gsub("\n","\n ",$OpenURL);
# fix bug: If text length > 2120, Google reports "Error, that's all we know"!
#alert(length($OpenURL)); $OpenURL=substr($OpenURL,0,2120);
if (length($OpenURL)>2120) {
setclipboard($SelectedText);
$OpenURL=_("Selection too long. Please right-click and paste (CTRL+V) ");
$OpenURL=sub("<txt>",urlencode($OpenURL),gsub("<from>",$_from,gsub("<to>",$_to,getpref(STRING,$_Translate_pref_text))));
}
&OpenURL_Selected;
}
Also after saving the macro again, the entry in context menu fell all down to the end of my long menu with selection-context-macros. Fixed by adding position:
# context menus
old: setmenu(Selection,popup,$__s);
new: setmenu(Selection,popup,$__s
,"Sen&d By Mail...");
Update:
Meanwhile noticed, google also
refuses to translate whole https-pages...
No, not true! It's actually not google that denies, but just the macro itself that wrongly thinks google would!
After modifying the restriction for "
https://" sites to "http" all works fine for example on wikipedia page
https://ru.wikipedia.org/wiki/ТектологиÑ
May well be that REALLY protected sites cannot be translated, but nowadays all sorts of public sites redirect to https too, so guess we could leave the error message to google itself - but only if it really doesn't work...
Edited 3 time(s). Last edit at 11/25/2015 07:28PM by siria.