Category Archives: Google translate

Embedded website translation using google translate

Now we all know everybodies favourite search engine, Bing – just kidding – Google, is very capable of returning accurate searches quickly and easily simply by entering text into googles search box area and then hitting search button. For most users, thats all they need from it and continue on their way. However, under the covers of such a simple interface lies a very powerful albeit not obvious scripting API. For example, checking if your site is being indexed by their crawler. In this case, one can simply type into the normal search text area the site url value prepended with the keyword “site” e.g. site:www.[name of your site].com, the colon that appears is a token that is require that aids in distinguishing the separation between key and value pairs. After hitting the search button any pages that were crawled will be listed in the results.

Today I wanted to go a little further and see what else was under there. Moreover, I wanted a way to use googles own translation website such that it would automatically translate text without having to be copied and pasted into itself.

Using baidu’s home page as an example we can see that unless one is fluent in Chinese this site would normally present a problem to English speakers.

Baidu pre translated

Baidu pre translated

After a bit of tinkering I have found the minimum requirements to get this working using is as follows. The website uses a set of specific query string parameters to communicate with the API, these include:

hl – host languge

sl – source language

tl – translated languge

u – url

When these are entered correctly into the end of, e.g.

we receive the following results:

Baidu post translated

Baidu post translated

As you can see, we have the same website now with all text in chinese fully translated, what is even better is the links within the page work and you can traverse the site as if it was a normal website.