Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


How can I make my site available in multiple languages?

I know that it's not optimal, but I want to make the product information pages on my online store available in a bunch of different languages without paying the major bucks to get a professional translator to maintain them. I know that services like Babelfish let you enter a URL and get the contents translated automatically, but is there some way to hook that into a site directly?


Dave's Answer:

You're right, and you're right. It is the case that machine translation through services like Altavista's Babelfish are inferior to having a human translate them (for a good discussion of why this is the case, please see my earlier article why human translators are better than machine translation).

Nonetheless, if you want something quick and dirty and are willing to accept that the results might be somewhat cockeyed, weird, puzzling or inadvertently amusing, then automated machine translation can be a good option.

Rather than Altavista's service, however, I'm more of a fan of Google's Translation Service (I swear, I'm not on Google's payroll, I just like their products and services!).

Fortunately for both of us, my friend Brad Feld recently added an automatic-translation feature to his popular blog and his programmer blogged about it, including showing his custom code to achieve the translation. Sweet indeed!

Ross (the programmer) shows the following as a self-contained snippet of Javascript + HTML to have a pull-down translation capability:

<select name="translate" style="height:18px; font-size:10px;" onchange="javascript:window.location = http://www.google.com/translate_c?hl=en&langpair=en%7C' + this.value + '&u=' + window.location.href;">
    <option value="">Translate This Page</option>
    <option value="ar">Arabic</option>
    <option value="zh-CN">Chinese Simplified</option>
    <option value="zh-TW">Chinese Traditional</option>
    <option value="nl">Dutch</option>
    <option value="fr">French</option>
    <option value="de">German</option>
    <option value="el">Greek</option>
    <option value="it">Italian</option>
    <option value="ja">Japanese</option>
    <option value="ko">Korean</option>
    <option value="pt">Portuguese</option>
    <option value="ru">Russian</option>
    <option value="es">Spanish</option>           
</select>

As you can see, it supports quite a few of the languages Google offers, for better or worse. If you don't want to support them all, just axe a few lines from the code block, so you can, for example, just offer translation into French, Spanish and Italian if you wanted.

How's it work? Well, here's an example with the code actually live:

Try it, check out this very page in Russian or Greek. Cool, eh?

You'll notice that Ross has added some CSS style attributes to the select statement too: if you don't like how he's set things up, you can definitely tweak 'em to get a different result.

Hope that helps you add this capability to your site. Let us know how it works out with your overseas and non-English speaking customers.


More Useful HTML, JavaScript and Web Site Programming Articles:
✔   How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔   Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔   Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔   How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔   How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  





Categorized: HTML, JavaScript and Web Site Programming   (Article 7880, Written by )
Tagged: babelfish, language translation, machine translation
Previous: Did MySpace introduce a new type of friend invitation?
Next: How can I add "translate into" country flags to my pages?




Reader Comments To Date: 33

daily said, on February 14, 2008 8:30 AM:

This is great, we have a small business in the uk and have many European customers.. It works nicely, how do you automatically remove the google frame?

VINCE said, on February 21, 2008 1:46 AM:

how do you automatically remove the google frame?

rambow245 said, on March 16, 2008 7:18 PM:

for some reason i keep getting a error on my website have any ideas how to fix it? check it out www.ocsc.info

Darren said, on April 8, 2008 2:25 AM:

Hi Dave,

It would be really useful if you could figure how to automatically remove the frame.

Darren said, on April 9, 2008 9:44 AM:

Hi Guys,

I now know how to remove the frame, it dones by a simple break out script. Include the below in the body of the website you are translating:

<script language="javascript" type="text/javascript">
if (top.location != self.location) {
top.location.replace(self.location); // pop to top
}
</script>

It will remove the frame after translation.

Darren said, on May 28, 2008 2:56 AM:

for some reason i keep getting a error on my website have any ideas how to fix it? check it out www.ocsc.info
Posted by: rambow245 at March 16, 2008 7:18 PM

The reason your does not work is your using a CMS system which uses GET method to retrieve the page information - as google is not the same URL anymore the GET method is not pointing correctly thus it wont work.

val said, on May 29, 2008 6:22 AM:

Hello,

I added the code but it doesn't work. I have no idea why, just nothing happens when I select another language.

Can you help?

Thanks so much, Val

Ron said, on August 15, 2008 11:56 AM:

Is there a way to somehow link back to the content in the original language? I could use some help with this.

TIA.

Darren said, on August 19, 2008 2:25 AM:

You could add a "back to main language" link or a home link to your domain, this will send the user back to the original language as by translatibng they actually navigate away from your site.

Georgie Imtiaz said, on September 4, 2008 4:57 AM:

Does any one know how to use a translator in an outlook email so that it converts the email into other languages remaining inside the Outlook??

Steven said, on October 2, 2008 10:31 AM:

Your may also be interested in http://www.conveythis.com which offers a free button you can insert into your layout (kind of like addthis.com) which creates a little pop-up/drown-down menu that allows visitors to select their translator and language of preference without having to ever actually leave the page. It's a pretty convenient and simple solution to this situation.

.oOLimOo. said, on December 2, 2008 7:00 AM:

Does this work for all browsers? I am unfamiliar with java.

Brian Morin said, on November 28, 2009 3:30 PM:

Thank you for this it is very nice, but I have been trying tabulator code and services all day today, at least 6 hours. It is for my wifes page, that is in French, and needs to be translated, without effort, buy her lady friends.

http://shakti-lanaudiere.ning.com/

I have tried the Ning translator, that basically links to Google Translate, and it works so beautiful, until the translation is complete, then it breaks frame.

I used the Convoy, that gives a choice of several different services, including Google. The ones that don't break frame, really mess up the formating of the page, to the point that nothing is really recognizable.

I also have yours there now, and on this type of site, it does not work. I am really stumped!

Any and all suggestions are heartily excepted.

bri

Brian Morin said, on November 28, 2009 3:50 PM:

I just chnaged a little bit of the code. I changed the 'en' to 'fr' without the quotes and added a line for the english, and the sucker is working like a charm!!!!!! Ya hoooooooooo!

bri

Thanks for your beautiful work. - bri

Brian Morin said, on November 28, 2009 5:09 PM:

Up one minute down another. Now, for some reason, it is no longer working on my ning site!?

Just thought I'd let you know.

bri

Brian Morin said, on November 28, 2009 5:29 PM:

Is this a roller coaster ride or what, I stripped out some code by mistake when I made some changes in Notepad and copied them over to my page.

I won't do the big high thing this time, but I am very happy!

bri

Brian Morin said, on November 28, 2009 5:59 PM:

I'm a philosopher not an IT, and I always thought that computers were an exact science. Oh was I wrong.

This code works for a while, great translation, closes frame, and keeps the translation, then BOOM! The translation is gone. But it did work before??? Any ideas?

bri

kerry kwiecinski said, on November 29, 2009 1:14 AM:

Hello, I don't know if this contact is working or not (I've tried different blind contacts but never heard back) so I'll try. I googled a question and your URL came up regarding making a website multi language. I mentioned my website up above. I wish to have the "flag" type of set-up on my web pages for language selection for the reader. I've got the site this far but when I get to reading java script /php/and the rest of the alphabet I'm lost, regarding these language options. I'm not a computer techie. I'm on a mac osx 10.4.11/2GHz/PowerPC G5/memory 512 MB DDR SDRAM, whatever that means. Is there someone who could do this conversion to 40+ languages? and for what cost? etc.
Look forward to hearing back
regards
kerry

silviya howe said, on June 11, 2011 4:54 PM:

Thank you for that,very helpfull article

Raymond Agbunag said, on June 18, 2011 1:45 AM:

This is really really great. Save a lot of time and effort. Thank you Mr. Dave!

Raymond A. said, on June 18, 2011 2:59 AM:

Hmn. When I choose the Language it doesn't load to the translated version. What's missing? Anyone help?

Thomas said, on June 28, 2011 10:07 PM:

To get a working version, look at the source for this page and following the "How's it work" segment you will see a snippet of working code.

TR

yogesh said, on July 14, 2011 12:38 AM:

hi...
i'm a final year student of B.E. in vadodara. i have to submit a project in my college. and i'm working on project named online survey software. I want to add general languages in my software using .net concept. so can u help me by suggesting how to add general languages like fench,geman,chinese,hindi,etc etc... i'm eagerly waiting for your reply. so as soon as possible. thank you...

Vadim said, on July 14, 2011 4:29 AM:

Hi guys! If someone need to translate your web site into russian or you know someone who need this service, I can help with this question.

ankit dulal said, on July 23, 2011 2:40 PM:

hello .i am from nepal.i donot know how to use please give me idea mr dave.so help me what to keep what in my site.

susheel said, on August 16, 2011 4:08 AM:

well 4 this u need to implement localization of content this is supported in every language. if it is in asp.net c sharp here is a very good tutorial

http://www.susheelonline.com/2011/08/hello-localized-world/

Chris Gauthier said, on February 1, 2012 8:22 AM:

Does this have any effect on SEO? Also, can you submit your website to different directories in countries that only except URL's with that language?

Mukesh Jat said, on February 3, 2012 3:29 AM:

I want to translate site... But Not using google .. I want to use my own words... what should i use.. php translator or use Mysql in it??

Avirat said, on March 1, 2012 11:44 AM:

Hey, this is really a super cool stuff. i really needed this from a long time and today just got to it by google. Thanks for the code.

Nancy said, on May 25, 2012 9:41 AM:

HI GUYS,

I am new to java , and i need to translate the website and it contents to other languages using java. can you please help me in that, i.e where i have to write the code like in RAD OR Eclipse? and what is the code for example? and where i have to run the code like server or jAVA etc..can you please help me ..? thanks in advance

amar said, on June 21, 2012 7:52 AM:

Hi we have one private url. i need to translate the whole apllication in to multiple languages..i dnt know how to do that, can you please reply me ...thanks in advance

asit said, on November 22, 2012 4:31 AM:

This code not working? what more modification require?

Shambhavi said, on March 14, 2013 3:46 AM:

DO you all have any idea of ecommerce website that uses multiple language for catalog/checkout- basically everything

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

I do have a comment, now that you mention it!











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.