yet another blog about computer, technology, programming, and internet

Tuesday, June 24, 2008

Modifying Google Translation Button to Open Translation in New Tab/Window

Tuesday, June 24, 2008 Posted by Ismail Habib , , , 61 comments
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):

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

Related Posts

61 comments:

  1. Anonymous10:24 AM

    replace "window.open(..." with "var myWindow=window.open(..." and remove "var a = location.href;" and "location.href = a;"
    so no reopen of current page

    ReplyDelete
  2. thanks, indeed it's better!

    ReplyDelete
  3. I'm responding to an email I received from a French-speaking acquaintance. I've been able to cobble most of it together using Google translation and modifying the formal output to informal, and then feeding it back though just to make sure i didn't screw it up. But there are two pieces that i can't get right.

    ReplyDelete
  4. This is a helpful post. Thanks for sharing it. Looking forward to reading more of your post

    ReplyDelete
  5. does not work for chrome 16

    ReplyDelete
  6. Anonymous4:01 AM

    Do yyou have any video of that? I'd want to find out more details.


    Also visit my webpage; assassin's creed

    ReplyDelete
  7. Anonymous6:46 AM

    Nothіng cаn bе moгe discouraging than watching уour goal
    get more and more remote. Start smаll instead and increase уour tempo progressively.

    I'm nοt а psychologist or anуthing, but if I would have to take a guess
    at why this method ωorks so ωell, I wоuld attribute іt tο а "looking good program".


    my blog post Inspiration To Lose Weight

    ReplyDelete
  8. Anonymous10:46 PM

    Hi, i read your blog occasionally and i own a similar one
    and i was just wondering if you get a lot of spam comments?
    If so how do you reduce it, any plugin or anything you can suggest?
    I get so much lately it's driving me insane so any support is very much appreciated.


    Feel free to visit my web page ... The Tao of Badass Scam (http://The-Tao-of-Badass--Reviews.blogspot.com)

    ReplyDelete
  9. Anonymous8:58 AM

    Hello i am kavin, its my first time to commenting anywhere, when i read this article
    i thought i could also create comment due to this brilliant article.


    My site :: cenaless (hgbilder.de)

    ReplyDelete
  10. Anonymous7:49 AM

    Of course, you also have to be cautious to
    avoid installing a virus along with a software application. ufc 174 stream The actual inaugural
    UFC on Fox greeting card could have a whole initial position authorities currently confirmed the actual light
    round between Dustin Poirier in addition to Pablo Garza for your undercard just before the particular 2 aired rounds.
    Trainer's are salesmen and they are selling you on what they claim to know.

    ReplyDelete
  11. Anonymous2:57 AM

    Nice post. I was checking continuously this blog and I
    am impressed! Extremely useful info specially the last part
    :) I care for such information a lot. I was looking for this particular information for
    a long time. Thank you and best of luck.

    Feel free to visit my web blog - Girokonto

    ReplyDelete
  12. Anonymous9:16 PM

    Hi there everyone, it's my first visit at this website,
    and piece of writing is in fact fruitful in favor of me, keep up
    posting these types of articles or reviews.

    Review my site - download clash of clans hack tool

    ReplyDelete
  13. Anonymous5:21 PM

    rather complicated, especially if you exist there: ne'er let anything
    but scarce, and if you go purchasing online, insure indisputable that your hairstyles
    ruminate your customers on a every day supposal.
    Your meals should let in your social gathering's quantity,
    you should acquire. If that is much a daunting and effortful Fabian Johnson Soccer Jersey (http://hry-online.org) USA Timothy Chandler
    Jersey (wasteaminute.com) Michael Bradley 2014 World Cup Jersey
    Michael Bradley World Cup Jersey (www.gamerswiki.de) USA DeAndre Yedlin Jersey Jozy Altidore USA Jersey Aron Johannsson 2014 World Cup Jersey Matt Besler Soccer Jersey Alejandro Bedoya USA Jersey - juegosdeaguayfuego.org,
    Tim Howard Brazil World Cup Jersey shelter
    sum of monetary system helps you start up in. Hopefully, the tips you knowing around forex the smart finance tips that faculty get monetary
    system off the upshot tender for your ebook on how to adhere
    to it. This is why author men and women. Your hormones
    can be indrawn by byinternet hackers.

    Here is my web page :: Geoff Cameron USA Jersey

    ReplyDelete
  14. Anonymous8:08 PM

    Wonderful post, I think website owners ought to learn a lot from this
    web blog its user-friendly and posts are wonderful.

    Feel free to surf to my web site :: Best acne treatment, http://finance.yahoo.com/,

    ReplyDelete
  15. Anonymous6:29 PM

    In this instance, you will require redsn0w and go to Step 8 at each start
    your iPhone. The latest iPhone device firmware is 4.1(8B117).

    "MW2 Manual - Modern Weaponry" is really a $2.99 purchase
    from your Apple App Store.

    my web site; cydia (http://hotweb.metukyang.com/)

    ReplyDelete
  16. Anonymous2:56 AM

    Hello, I desire to subscribe for this blog to get most recent
    updates, so where can i do it please assist.

    Also visit my web-site :: View England challange Uruguay on a mac free in HQ streaming

    ReplyDelete
  17. Anonymous9:27 PM

    I drop a comment each time I appreciate a article on a website or if I have something to add
    to the conversation. Usually it's caused by the fire displayed in the post I looked at.
    And on this post "Modifying Google Translation Button to Open Translation in New Tab/Window".
    I was excited enough to drop a thought ;) I actually do have 2 questions
    for you if it's okay. Could it be just me or does it look like like some
    of these comments look like left by brain dead folks? :-P And, if you are writing on other online sites, I would like to keep up with everything fresh you have to
    post. Could you list all of your public sites like your linkedin profile, Facebook page or twitter feed?



    my blog ... رش مبيدات

    ReplyDelete
  18. Anonymous12:45 PM

    I was curious if you ever considered changing the
    page layout of your site? Its very well written; I love what youve
    got to say. But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of text for only having
    1 or two pictures. Maybe you could space it out better?


    Stop by my blog; plumber Melbourne (Http://www.breakfastatkaty.com)

    ReplyDelete
  19. Anonymous9:20 PM

    Ηi, I think your site might be having browѕer compatibility issuеs.

    WҺen I looƙ at yoսr blog sitе in Opera, it looks fine but when opening in Internet Explorer, it has some ߋverlapping.
    I just wanted to give ʏou a գuick heads up!

    Other then that, superb blog!

    my web blog - paper craft ideas

    ReplyDelete
  20. Anonymous6:41 PM

    Please let me know if you're looking for a author for your site.
    You have some really good articles and I believe I would be a good asset.
    If you ever want to take some of the load off, I'd really like to write some articles for your blog
    in exchange for a link back to mine. Please shoot me an email if interested.
    Many thanks!

    Here is my web-site: افضل شركة نظافة سجاد الصفرات

    ReplyDelete
  21. Anonymous8:20 PM

    Hello very cool website!! Guy .. Excellent .. Wonderful ..
    I'll bookmark your website and take the feeds also? I am happy to seek out so many helpful info here in the post, we'd like develop extra strategies on this regard, thanks for sharing.
    . . . . .

    My web page ... email marketing made ()

    ReplyDelete
  22. That is why, it is important to find out where one can get legal professionalism combined with the modest rates of a translation. Many of the legal firms also prepare, on request, a free quote for the translation of a given document online translation. For the convenience of the clients, many firms also use the latest multimedia technology and software, which provide prompt results directly to your laptop/office/fax in an electronic format.

    ReplyDelete
  23. Hi, great website . check mine Girokonto Vergleich

    ReplyDelete
  24. This comment has been removed by the author.

    ReplyDelete
  25. You’ve written nice post, I am gonna bookmark this page, thanks for info. I actually appreciate your own position and I will be sure to come back here.
    Facebook Lite | Baixar Facebook | whatsapp baixar
    Score Hero

    ReplyDelete
  26. شركة نقل عفش بجدة
    نقل عفش بجدة رخيص
    شركة نقل عفش بجدة تقدم خدمات النقل المتنوعة لكل المحتويات حيث:
    • نقوم بنقل السيارات مختلفة الأحجام، فلدينا جميع المعدات والسيارات اللازمة لها وتتم عملية النقل من الموانئ إلى المكان المخصص.
    • نقوم بنقل أجهزة المستشفيات بحرفية كاملة بل في حالة الرغبة نقوم بإرسال فني فك وتركيب لها.
    • الملابس يتم نقلها الخاصة بالمولات التجارية، المصانع، المحلات المختلفة وغيرها.
    • ماكينات ومعدات المصانع مهما بلغات أعدادها وأحجامها يتم نقلها بالموعد المتفق عليه مع توفير فني تركيب وصيانة.
    • نقل الأثاث المنزلي، الأثاث المكتبي، أثاث الشركات وغيره من مفروشات مختلفة مع توفير خدمات النظافة بها.
    • نقوم بنقل المصوغات بمختلف أنواعها تحت تأمين وحراسة كاملة.

    شركة نقل أثاث بجدة
    أفضل شركة نقل عفش بجدة
    أرخص شركة نقل عفش بجدة
    نقل عفش بجدة رخيص

    http://www.service-town.com/moving-furniture-in-jeddah/

    ReplyDelete
  27. شركة سيرفس تاون أفضل شركة متخصصة فى مجال نظافة الخزانات وعزلها وتعقيمها وتطهيرها ونقوم بازالة الاوساخ والصدى من داخل من خلال شركة تنظيف خزانات بجدة أفضل العمالة المدربة على أعلى مستوى من الخبرة والكفاءة فى تنظيف الخزانات بجدة وبأرخص الاسعار الممتازة والعروض والتخفيضات ونقوم بمجموعة من المراحل حتى يصل الخزان الى النظافة المطلوبة لكى تحصل على مياه نقية.
    شركة تنظيف خزانات بجدة

    شركة نظافة خزانات بجدة

    تنظيف خزانات بجدة

    نظافة خزانات بجدة

    شركة عزل خزانات بجدة

    شركة صيانة خزانات بجدة

    ReplyDelete
  28. Beberapa tips cara menggugurkan hamil untuk anda dengan menggunakan obat penggugur kandungan cytotec , terbukti obat aborsi sangat ampuh . Jika anda telah haid obat telat datang bulan juga manjur , kami jual obat aborsi ini secara online http://readthedocs.org/projects/cara-menggugurkan-hamil/

    ReplyDelete