The translation button from Google has proved to be very useful in most situation (by me), especially since the language detection was introduced. However, I feel that there is something lacking. The problem is that the translation generated replaces the current active window/tab while sometimes I prefer to have another window/tab open. The translation button itself is a JavaScript, so we can play with is just a little bit. Here is the original code for translation button (I use the code for translation into English):
In order to make the translation to be opened in a new window/tab, we just have to make a bit change in it:
If you hate this kind of stuff, just drag and drop the link below to your browser toolbar:
Translate to English
I hope this is useful. Please let me know if you have a better idea. Obviously, any questions are welcome.
edited: thanks for the suggestion
javascript:
var t = ((window.getSelection&&window.getSelection()) || (document.getSelection&&document.getSelection()) || (document.selection&&document.selection.createRange && document.selection.createRange().text));
var e = (document.charset || document.characterSet);
if (t!='') {location.href='http://translate.google.com/translate_t?text=' + t + '&hl = en&langpair=auto|en&tbb=1&ie=' + e;} else {location.href='http://translate.google.com/translate?u=' + escape(location.href) + '&hl = en&langpair=auto|en&tbb=1&ie=' + e;};
In order to make the translation to be opened in a new window/tab, we just have to make a bit change in it:
javascript:
var t = ((window.getSelection&&window.getSelection()) || (document.getSelection&&document.getSelection()) || (document.selection&&document.selection.createRange && document.selection.createRange().text));
var e = (document.charset||document.characterSet);
if (t!='') {var myWindow=window.open('http://translate.google.com/translate_t?text=' + t + '&hl=en&langpair=auto|en&tbb=1&ie='+e,'Translation','')} else
{var myWindow=window.open('http://translate.google.com/translate?u=' + escape(location.href) + '&hl=en&langpair=auto|en&tbb=1&ie=' + e,'Translation','')};
If you hate this kind of stuff, just drag and drop the link below to your browser toolbar:
Translate to English
I hope this is useful. Please let me know if you have a better idea. Obviously, any questions are welcome.
edited: thanks for the suggestion
6 comments: