| |||||||
| Top Tip : Click here to Boost Your PC & Chrome Browsing Speed |
![]() |
| | Thread Tools | Display Modes |
|
#1
| |||
| |||
| Hi everyone, yesterday I decided to upgrade a script that was making an interrogation to Google web page translate. Actually the one I've seen could only translate the current page in English... not very versatile. So I decided to add a prompt where you can type the language you want Google to translate the page in. The prompt allow a string of 2 chars as input and if it doesn't represent any language (as 'zz') then the default 'en' is used. That's the code of the script: javascript:A14nH=location.href; L3f7=prompt('Choose%20destination%20language%20(2%20chars%20abbreviation):%20','en'); if(L3f7.length==2) {location='http://translate.google.es/translate?u='%20+%20encodeURIComponent(A14nH)+'&sl=auto&tl='+L3f7;}else{alert ('Invalid%20language%20abbreviation.')} Finally all the power of translation is at the reach of our cursor! Now I can enjoy to translate pages from Chinese to Arabic in a click! ![]() Gianluca Last edited by Gianluca Ferrario; 04-08-2009 at 06:51 PM.. |
|
#2
| ||||
| ||||
| Really useful! but it would be useful to know the language abbreviations.. because I typed in fr for French and it gave me another language. Thanks |
|
#3
| |||
| |||
| Abbreviations are the same that Google translate use, so 2 letters written in lowercase. I suppose these abbreviation comes from ISO 639. In your case French is fr. When I will have some time I will try to create a script that validate the language name string. |
|
#4
| ||||
| ||||
| OK, it works, but the only thing is that the header put on the top of the page says this: "Esta página ha sido traducida automáticamente. Volver a la página de traducción Ver la Página Web Original" which I suppose is spanish... Is there any way of making that english instead? Thanks |
|
#5
| |||
| |||
| well, just change the query to translate.google.com instead of translate.google.es. I live in Spain so I forgot to change it... |
|
#6
| ||||
| ||||
Ok thanks! |
|
#7
| |||
| |||
| Hi, I just finished to upgrade this bookmarklet. Now it can translate a whole page in the desired language OR you can simply select with the mouse a text to be translated that is in the page and then click on the bookmarklet to have the translation in a popup window. Enjoy! javascript:function x(){loc=location.href; lang=prompt('Choose%20destination%20language%20(2% 20chars%20abbreviation):%20','en'); if (lang.length==2){flag=true;}else{flag=false; alert ('Invalid%20language%20abbreviation.')}text = ''; if (window.getSelection) { text= window.getSelection(); } else if (document.getSelection) { text = document.getSelection(); } else if (document.selection) { text = document.selection.createRange().text;}}function y(){if((flag==true) && (text=='')){location='http://translate.google.com/translate?u='%20+%20encodeURIComponent(loc)+'&sl=a uto&tl='+lang;}} function z(){if ((flag==true) && (text!='')){ var res=window.open('http://translate.google.com/translate_t?text='+text+'&sl=auto&tl='+ lang ,'gTranslate_popup','left='+((window.screenX||wind ow.screenLeft)+10)+',top='+((window.screenY||windo w.screenTop)+10)+',height=500px,width=640px,resiza ble=1,scrollbars=1');window.setTimeout(function(){ res.focus()},300)}} x(); y(); z(); |
|
#8
| |||
| |||
| Did the last bookmarklet work for anybody ? |
|
#9
| |||
| |||
| well, I think yes. What's the problem? |
|
#10
| |||
| |||
| The first link provides works as a charm, however the last just doesnt work. No reaction. All I did was created a Bookmark through the Bookmark manager, the same way I created for the first one |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| editing/skinning the default home page (most visited page) | jbell | Chrome Plugins | 1 | 03-14-2009 03:49 AM |