Because the Web is a global space, we've all come across pages in different languages, especially among search results. If you're searching for information about a phrase like hamburger recipe, it's strange to come across a page about it in German. It's stranger still to find a mention of your name on a page in a foreign language. Imagine my surprise when I was searching Yahoo! for my name and found it at the Russian site shown in .
I can't read Russian, so of course I had no idea what the text said. I had recently added a photo gallery of old radio dials to my web site; I could tell they were linking to it, but I wanted to know what they were saying.
Yahoo! Language Tools
Yahoo!'s Language Tools page (http://tools.search.yahoo.com/language) has some ways to help you work with other languages. Among them is a translation service that will translate any block of text to a different language. I copied the Russian text from , pasted it into the text area labeled "Translate this web text," chose "From Russian to English" from the drop-down list of languages, and clicked Translate. Yahoo! responded with this:
Radio Dials. The gallery of the photographs of ancient, I will not be
afraid this word, radios-scale. The author of collection, photographer
Paul Bausch, decided thus to publish the paternal collection of radio
receivers. 3x, dreams about their own tsifrozerkalke with the
macro-objective become increasingly more importunately.
As you can see, the Yahoo! translation tool isn't perfect, but it's good enough to give a sense of what the page is talking about. The translated text refers to the "paternal collection" of photos, because the radios I photographed belonged to my father. I still have no idea what the last sentence of the translation means, but I'm closer to understanding now than when it was in Russian.
If you'd like to limit the search results that Yahoo! returns to one language or a handful of languages, you can set your preferred languages in your search preferences. By default, Yahoo! returns the best search results from any language.
A faster way to translate any page you find in Yahoo! Search results is via the "Translate this page" link included within the results for non-English pages. highlights the link in the search results.
Figure 2. The "Translate this page" link in Yahoo! Search results
Clicking the "Translate this page" link takes you to a translated version of the page, rather than the page in its original language.
If you find yourself translating pages frequently, there are some ways to speed up the process. You can translate an entire web page by copying and pasting the URL into the field labeled "Translate this web page" on the Yahoo! Language Tools page, choosing the language from the drop-down menu, and clicking Translate. Yahoo! will display the page with all of the text translated.
Another quick way to translate entire pages is with the Yahoo! Toolbar . If you've already installed the Yahoo! Toolbar, choose Add/Edit Buttons… from the Toolbar Settings button to bring up the Customize Yahoo! Toolbar page. Check the box next to Translate Current Page under Search & Navigation and then click Finished. You should now see a small yellow fish button, like the one shown in , on your toolbar.
Figure 3. The Translate button on the Yahoo! Toolbar
From any web page, you can click the Translate button and Yahoo! will display a version in English. Yahoo! will also automatically detect the source language, so you don't need to choose a language from a menu. This is also handy if you can't tell what language the page is in. If you just want to translate a block of text instead of the entire page, you can click the arrow next to the fish and choose Language and Translation Tools from the menu; you'll go to the Yahoo! Language Tools page, where you can paste the text you want to translate into the translation form.
A Translation Bookmarklet
If you visit the Yahoo! Language Tools page and translate a page by URL, you'll end up at a Yahoo! page that uses frames. The top frame includes the Yahoo! Search logo and several links: View Original, Print Translation, Language Tools, and so on. The bottom frame is the original web page, with all of the text translated into a different language. shows such a translated page, with the O'Reilly Hacks page in Spanish in the bottom frame.
Figure 4. The Hacks site translated into Spanish
Looking at the URL in the address bar, you'll see that you're at a Yahoo! page with some parameters passed to it in the querystring, including the URL of the page to be translated. The whole URL looks like this:
Here are the three variables passed in the URL:
The type of translation to perform
The URL of the page to translate
A code that represents the language to translate from and to
Knowing how to build Yahoo! Translate URLs, you can create a bookmarklet to fetch the current page URL, construct the proper Yahoo! Translate URL, and open it in a new window.
The value of the lp variable in this code is important to note. The value xx_en tells Yahoo! to determine the language of the page you've sent it to translate. Of course, you could make this a language-specific bookmarklet by replacing xx_en with es_en (Spanish to English), fr_de (French to German), or any one of the other codes for the translations that Yahoo! supports. To view a full list of translation codes, simply view the source of the Language Tools page and look at the value attribute in the <option> tags that display the language choices. There are a few option lists on the page, so look for the list that contains values in the xx_yy format.
Running the hack.
To run the code, browse to a foreign-language page and
click Yahoo! Translate from your bookmarks. A new browser window will
open, showing a translated version of the original page. shows a Japanese page in the background that has been translated into English in the foreground.
Figure 5. A page that has been translated from Japanese to English
The automatic translation might provide less-than-fluid English, but if you ever find your name on a page in a language you don't speak, you can find out why with a single click.