• Bookmark
  • Print this page
  • Digg
  • Del.icio.us
  • Reddit
  • Yahoo!
  • Google
  • Furl
  • Ma.gnolia
  • NewsVine

How to Add Google Translation to Your Website or Blog Using PHP

Note: Due to repeated abuses, hotlinking to the images is no longer allowed, please download the images and host them on your own server. Sorry for the inconvenience.

Image is Creative Commons No Rights Reserved Public Domain By publishing in only one language you leave out many users and potential clients. According to WorldLingo, a website translation company, around 65% of people on the web speak a language other than English. To publish in other languages I use Google's Language Tools. Google offers excellent and free one click translation from English to Arabic, Bulgarian, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hindi, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Romanian, Russian, Spanish, and Swedish. Google translates the text and then presents the page with the correct formatting for that language, such as right to left text.

Unfortunately, Google does not offer a way to integrate it's translation service within your site. WorldLingo and AltaVista do, but it either costs money (WorldLingo starts at $40 a month) or requires you to display their rather rather large, preformatted logo. However, with a little bit of PHP you can embed Google translation into all of your pages simply by copying and pasting some code. PHP and (X)HTML is the most elegant solution, as it's entirely independent the end-users' browser settings. You need to have PHP installed on your server for this to work.

Translation Option One: Flags Ver. 2.0

Below is the the flag based version, I believe these are the most politically correct versions.

العربية Български 简化字 正體字 Hrvatski čeština Dansk Nederlands Suomi Français Deutsch ελληνικά हिन्दी Italiano 日本語 한국말 Norsk Polski Português Români Русский Español Svenska Learn More
Open up the section below and copy and paste the code into your website to use the flag translation used above. Please remember to download the images and host them on your own server.

Click to view code

Translation Option Two: Images Ver. 1.5

Note: This will be updated soon to the newer version with more languages

Below is the image-based version. The included images have the word for that respective language on them. Many of the characters in these languages are incompatible with the standard character set of most users. Using an image of the word will make sure that the word will show up correctly to the user. It's also arguably more politically correct, rather than associating a particular flag with a language.

Deutsch Espanol Francais Italiano Portugues Russian Arabic Japanese Korean Simplified Chinese Learn More

Copy and paste the code below to use language images translation service demonstrated above. Please remember to download the images and host them on your own server.

Click to view code

Translation Option Three: Text Links Ver. 2.0

Below is the text-link version, it produces links that appear like those below. They are unstyled, so when they are placed on your site they will assume the link style for your site. The disadvantage of these non-image based links is that Google tends to translate them so it can sometimes look messy.

العربية  Български  简化字  正體字  Hrvatski  Česky  Dansk  Nederlands  Suomi  Français  Deutsch  Eλληνικά  हिन्दी  Italiano  日本語  한국말  Norsk  Polski  Português  Români  Русский  Español  Svenska

Copy and paste the code below into your website to use the text link style demonstrated above:

Click to view code

Conclusion and Examples

I've been using the image based version on my site, located in the footer below, for the past few months and I've been very satisfied. Another example of the second translation option can be found at the East Hills Elementary website.

Kevin C. July 18th 2006 kcas88@gmail.com
Last Updated Aug. 16th 2008

<Back to Translation Portal

『It has been said that democracy is the worst form of government except all the others that have been tried.』 - Sir Winston Churchill