I use Google Reader to follow industry blogs about things like PHP and Java. One of the nice things that Google Reader does, is to automagically translate the page into English when the post is in a different language.

This is very helpful especially with blogs in subjects like these, especially since the international community is very active. Reader will give you a brief translated version of the feed, and when you click the link to go to the page, it typically forwards you through http://translate.google.com so you can read the page. For the most part, this yields a very understandable page that represents the subject the author was trying to convey very well.

To set this up in Google Reader, you just set the feed to automatically translate the page by clicking on the “Feed settings” button:

Translate_check_item

Notice that with the “Translate into my Language” checked, you’ll see “Translated by Google”  at the top of the page. The link to go to the post is now run through the http://translate.google.com with the appropriate languages so that you can read it, and if you click the “View original” link, you’ll see the summary in the original language.

In the above example, the feed looks like this, when I choose original language:

German feed

Clicking on the link for this post takes me to http://feeds.feedburner.com/~r/cakephp/~3/521947537/ which ends up at the blog for CakePHP & DIEVOLUTION, which looks like:

untranslated

Going back to the translated version, if I click on the link to go the the page, I get redirected to http://translate.google.com/translate?sl=auto&tl=en&u=http%3A%2F%2Ffeeds.feedburner.com%2F~r%2Fcakephp%2F~3%2F521947537%2F , which gives me the nicely translated page (below).

translated

So this got me to thinking: it should be a relatively simple thing to add a link to your page to send it to Google translate, to allow somebody to translate into their language, since it’s basically just an HTTP GET with parameters of the page, source language and destination language.

So I figured I’d try it with my blog first. I know the URL is http://blog.accuweaver.com, and my language source is EN (English). So to translate into German for instance, I need to create a URL that starts with http://translate.google.com/translate, and includes those two elements, and the language I want it translated to.

The parameters for the link are as follows:

parameter Used for value
u URL of page http://blog.accuweaver.com
sl Source language (English) en
tl Translate to language (German) de

So by putting these together, I get a link that looks like: http://translate.google.com/translate?u=http://blog.accuweaver.com&sl=en&tl=de, which when clicked will give me a German translation of my page.

Google also has a JavaScript widget that you can use to allow anybody to translate your page, which effectively builds the same sorts of URL’s for each language. You simply post some JavaScript code in your page which does some magic and places a little “translate tool” on your page (see http://translate.google.com/translate_tools?hl=en) and looks like the widget below: