Translation of Ficlets RSS Feeds Using Yahoo! Pipes and Google Translate
The purpose of this post is to show how to use Yahoo! Pipes in combination with Google Translate to not only translate a Ficlets RSS feed but also to modify the underlying URLs so that if these links are followed, the web pages viewed are translated as well.
Google Translate is a language translation utility that can translate either user-entered text or a web page. For the purposes of this post, we will focus on the web page translation functionality. As an example, here is http://dev.aol.com translated into German. You will see by inspecting the URL (http://www.google.com/translate) that there are four parameters:
- langpair: Defines the language translation scheme (see Table 1)
- hl: Sets the language in the top frame containing other Google Translate options
- ie: Sets the character encoding (default: UTF8)
- u: Sets the URL of the web page you wish to translate.
The langpair variable sets the "from" and "to" languages by using a code for each language while separating them by a pipe character ( | ). For example, to translate from English to German, the langpair parameter is set to "en|de". Table 1 shows all of the current options for translating between languages supported by Google Translate.
Table 1 - Language Pair Options (langpair parameter)| Translation Scheme | langpair parameter |
|---|---|
| Arabic to English | ar|en |
| German to English | de|en |
| German to French | de|fr |
| Greek to English | el|en |
| English to Arabic | en|ar |
| English to German | en|de |
| English to Greek | en|el |
| English to Spanish | en|es |
| English to French | en|fr |
| English to Italian | en|it |
| English to Japanese | en|ja |
| English to Korean | en|ko |
| English to Dutch | en|nl |
| English to Portuguese | en|pt |
| English to Russian | en|ru |
| English to Chinese (Simplified) | en|zh-CN |
| English to Chinese (Traditional) | en|zh-TW |
| Spanish to English | es|en |
| French to German | fr|de |
| French to English | fr|en |
| Italian to English | it|en |
| Japanese to English | ja|en |
| Korean to English | ko|en |
| Dutch to English | nl|en |
| Portuguese to English | pt|en |
| Russian to English | ru|en |
| Chinese to English | zh|en |
| Chinese (Simplified to Traditional) | zh-CN|zh-TW |
| Chinese (Traditional to Simplified) | zh-TW|zh-CN |
Although Google Translate can translate a web page, it will not translate an RSS feed. Here is an example of trying to use Google to translate an RSS feed. As you can see, it doesn't work.
Yahoo! Pipes is a utility that allows you to mix and manipulate various types of web data sources and output the resulting data as an RSS feed or JSON. There are many modules which you can use to manipulate data. For this post we will use 4 of these modules:
- Fetch Feed: Gets an RSS feed
- Loop: Loops through each item of a data source performing the operation defined by an embedded module
- Translate: Translates a string from one language to another
- String Builder: Creates a string by concatenating either user-defined strings or strings from an item of a data source
To create the pipe, the first step was to fetch the desired RSS feed. Ficlets has a recent story feed (http://ficlets.com/feeds/recent) that I wanted to translate into German. The second step was to loop through each item in the feed to translate the title element from English to German. This same process was done again but this time I translated the description element. At this point, the output of this pipe would be a translated RSS feed. The problem is that if you then followed a link contained in the feed to get more information, such as wanting to read a prequel or sequel in Ficlets, the web page would be in English not in the language of the translated RSS feed. This is where we get Google Translate into the mix. By again looping over each item of the feed, we can now use the String Builder module to replace any URLs found in the feed with a properly setup Google Translate URL as we discussed earlier in this post. See Figure 1 for the source of this Yahoo! Pipe and see Figure 2 for the output of a completed Yahoo! Pipe.

Figure 1 - Yahoo! Pipe Source.

Figure 2 - Running a Yahoo! Pipe.
As you can see, the Pipe can be rendered as RSS or JSON. The RSS version can also be easily added to your My AOL page. As you would expect, if you follow the links in the feed, these pages will also be translated by Google Translate.
Resources

