Unofficial Google Translate APIGoogle Translate

The other day Philipp Lenssen predicted that Google will have an API for Google Translate by 2009. “[Spanish of this blog was] automatically translated with the terrific Google Translation API. Several native speakers/ readers have told me the translations are absolutely fluent, except for the occasional weirdness due to cultural differences, or some very rare grammar hiccups.” he said.

I think that creating a Google Translate API would not just be cool, but extremely useful. Two days later, I start coding, clackety-clack, clackety-clack… Here I present you the beta version of the uOGT API, short for unOfficial Google Translate API.

Unlike others, uOGT allows users to translate selections of text by including them in a SPAN tag and with class “t”. For example,something to translate. Of course, like most of Google’s web APIs(though this is unofficial), this one requires you to include a JavaScript file to the pages that you want to translate as well(you will also need to upload a server-side file). So is it going to take longer to download the pages that included with the JS file? No, it won’t, because the file is so small - less than 800 bytes, in my example’s setting… (Google’s homepage is 10,000 bytes as today, including images)

To run uOGT, your server needs to have PHP version >=4.3 or 5 installed. The client-side script will work on most of the modern browsers(Firefox, Opera, etc…), except Internet Explorer(I am NOT anti-IE, I don’t know why it doesn’t work… I am working to resolve this issue).

You can download the file here[zip]. After extracting the files on the computer, you can edit the value of LP and URL in file “api.js”: LP is the language pairs to be translate, and the URL property should be the relative URL(which works better) for the server-side file, “translation.php”. Upload all the files, and run “example.html” in a browser, such as Firefox.

You can find a demonstration on the project page, as well as a simple example. This is pretty much it… Tell me what you think. :D

[inspiration and the image from Google Blogoscoped, Google logo is a trademark of Google, Inc]

UPDATE: The development of this project is no longer active, if anyone wants to continue the development, let me know.

UPDATE 2: There’s an official Translate API, but with a lot of restrictions. Also, Amos Vryhof is now responsible for the development of this unofficial API. You can find the latest fix on Google Code. Thanks Amos. :)