Revision: 19848
Updated Code
at July 15, 2011 23:30 by wizard04
Updated Code
/****************************************
Google translate bookmarklet
Select some text to translate, or don't select anything to translate the entire page.
/****************************************/
javascript:(function(){var%20t=window.getSelection?window.getSelection():document.getSelection?document.getSelection():(document.selection&&document.selection.createRange)?document.selection.createRange().text:'';if(t!=''){t=encodeURIComponent(t.toString());window.open('http://translate.google.com/translate_t?sl=auto&text='+t)}else{location.href='http://translate.google.com/translate?sl=auto&u='+encodeURIComponent(location.href)}})()
//Here it is expanded so you can read it:
javascript:(function(){
var t = window.getSelection ? window.getSelection() :
document.getSelection ? document.getSelection() :
(document.selection && document.selection.createRange) ? document.selection.createRange().text :
'';
if(t != '') //if text has been selected
{
t=encodeURIComponent(t.toString());
window.open('http://translate.google.com/translate_t?sl=auto&text='+t) //translate the text in a new window
}
else
{
location.href='http://translate.google.com/translate?sl=auto&u='+encodeURIComponent(location.href) //translate the page in the current window
}
})()
Revision: 19847
Updated Code
at March 9, 2010 08:48 by wizard04
Updated Code
/****************************************
Google translate bookmarklet
Select some text to translate, or don't select anything to translate the entire page.
/****************************************/
javascript:(function(){var%20t=window.getSelection?window.getSelection():document.getSelection?document.getSelection():(document.selection&&document.selection.createRange)?document.selection.createRange().text:'';if(t!=''){t=t.toString().replace(/\s/g,'%2520').replace(/\?/g,'%253F').replace(/&/g,'%2526').replace(/#/g,'%2523');window.open('http://translate.google.com/translate_t?sl=auto&text='+t)}else{location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href)}})()
//Here it is expanded so you can read it:
javascript:(function(){
var t = window.getSelection ? window.getSelection() :
document.getSelection ? document.getSelection() :
(document.selection && document.selection.createRange) ? document.selection.createRange().text :
'';
if(t != '') //if text has been selected
{
t=t.toString().replace(/\s/g,'%20').replace(/\?/g,'%3F').replace(/&/g,'%26').replace(/#/g,'%23');
window.open('http://translate.google.com/translate_t?sl=auto&text='+t) //translate the text in a new window
}
else
{
location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href) //translate the page in the current window
}
})()
Revision: 19846
Updated Code
at November 3, 2009 11:40 by wizard04
Updated Code
javascript:(function(){var%20t=window.getSelection?window.getSelection():document.getSelection?document.getSelection():(document.selection&&document.selection.createRange)?document.selection.createRange().text:'';if(t!=''){t=t.toString().replace(/\s/g,'%2520').replace(/\?/g,'%253F').replace(/&/g,'%2526').replace(/#/g,'%2523');window.open('http://translate.google.com/translate_t?sl=auto&text='+t)}else{location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href)}})()
//Here it is expanded so you can read it:
javascript:(function(){
var t = window.getSelection ? window.getSelection() :
document.getSelection ? document.getSelection() :
(document.selection && document.selection.createRange) ? document.selection.createRange().text :
'';
if(t != '') //if text has been selected
{
t=t.toString().replace(/\s/g,'%20').replace(/\?/g,'%3F').replace(/&/g,'%26').replace(/#/g,'%23');
window.open('http://translate.google.com/translate_t?sl=auto&text='+t) //translate the text in a new window
}
else
{
location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href) //translate the page in the current window
}
})()
Revision: 19845
Updated Code
at November 3, 2009 10:52 by wizard04
Updated Code
javascript:(function(){var%20t=escape((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));if(t!=''){window.open('http://translate.google.com/translate_t?sl=auto&text='+t)}else{location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href)}})()
//Here it is expanded so you can read it:
javascript:(function(){
var t = escape( (window.getSelection && window.getSelection()) ||
(document.getSelection && document.getSelection()) ||
(document.selection && document.selection.createRange && document.selection.createRange().text)
);
if(t != '') //if text has been selected
{
window.open('http://translate.google.com/translate_t?sl=auto&text='+t) //translate the text in a new window
}
else
{
location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href) //translate the page in the current window
}
})()
Revision: 19844
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 1, 2009 23:33 by wizard04
Initial Code
javascript:(function(){var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));if(t!=''){window.open('http://translate.google.com/translate_t?text='+t)}else{location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href)}})()
//Here it is expanded so you can read it:
javascript:(function(){
var t = ( (window.getSelection && window.getSelection()) ||
(document.getSelection && document.getSelection()) ||
(document.selection && document.selection.createRange && document.selection.createRange().text)
);
if(t != '') //if text has been selected
{
window.open('http://translate.google.com/translate_t?text='+t) //translate the text in a new window
}
else
{
location.href='http://translate.google.com/translate?sl=auto&u='+escape(location.href) //translate the page in the current window
}
})()
Initial URL
Initial Description
Select some text to translate, or don't select anything to translate the entire page.
Initial Title
Google Translate Bookmarklet
Initial Tags
javascript
Initial Language
JavaScript