Welcome guest, is this your first visit? Create Account now to join.
Page 1 of 2 12 LastLast
Results 1 to 10 of 19

This is a discussion on Instant Page Translator within the Chrome Plugins section, part of the Google Chrome category: Hi everyone, yesterday I decided to upgrade a script that was making an interrogation to Google web page translate. Actually ...


  1. #1
    Gianluca Ferrario is offline Junior Member
    Join Date
    Apr 2009
    Location
    Madrid
    Posts
    15

    Lightbulb Instant Page Translator

    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 05:51 PM.

  2. #2
    Stamga's Avatar
    Stamga is offline Super Moderator/Designer
    Join Date
    Mar 2009
    Location
    Qc, Canada
    Posts
    601

    Default

    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. #3
    Gianluca Ferrario is offline Junior Member
    Join Date
    Apr 2009
    Location
    Madrid
    Posts
    15

    Default Abbreviations

    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. #4
    Stamga's Avatar
    Stamga is offline Super Moderator/Designer
    Join Date
    Mar 2009
    Location
    Qc, Canada
    Posts
    601

    Default

    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. #5
    Gianluca Ferrario is offline Junior Member
    Join Date
    Apr 2009
    Location
    Madrid
    Posts
    15

    Default

    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. #6
    Stamga's Avatar
    Stamga is offline Super Moderator/Designer
    Join Date
    Mar 2009
    Location
    Qc, Canada
    Posts
    601

    Default

    Ok thanks!


  7. #7
    Gianluca Ferrario is offline Junior Member
    Join Date
    Apr 2009
    Location
    Madrid
    Posts
    15

    Default

    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. #8
    jkhan69 is offline Junior Member
    Join Date
    May 2009
    Posts
    3

    Unhappy

    Did the last bookmarklet work for anybody ?

  9. #9
    Gianluca Ferrario is offline Junior Member
    Join Date
    Apr 2009
    Location
    Madrid
    Posts
    15

    Default

    well, I think yes. What's the problem?

  10. #10
    jkhan69 is offline Junior Member
    Join Date
    May 2009
    Posts
    3

    Unhappy

    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

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 03-14-2009, 02:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •