Demo scenario - a sample feed reader to translate IBM China news. Using IBM Mashup Center, one can build a sample application that
- Pull the content from a feed (IBM China news)
- Use Google REST service to translate each page
- And present the result in an interactive application
This is your personal newspaper - you build it and you use it the way you like.
1.0. Create the feeds
Your company may publish news in the form of RSS or ATOM feeds. Most news are in English, and some may be in local country language. For the demo purpose of this mashup, I use the IBM China news. The feed is already cataloged on Greenhouse Mashup Center. You can either use it from the catalog (see image) or from the original URL (which is http://www.ibm.com/news/cn/zh/index.rss
2.0. Create data mashup
2.1. Figure out how to translate a Web page
Searching on the Internet, I found the Google translation tool which can translate a Web page. One can enter the URL of the page to be translated, selects the languages then hits the "Translate" button. The translated page is the result of a Google REST service - it has a URL that you can reuse.
For example, if one wants to translate the chinese page (http://www.ibm.com/news/cn/zh/2008/07/15/l414525z84931c06.html
), he/she can use this URL (http://translate.google.com/translate?u=http://www.ibm.com/news/cn/zh/2008/07/15/l414525z84931c06.html&sl=zh-CN&tl=en&hl=en&ie=UTF-8
). This URL is composed of 3 parts:
2.2. Used the REST service in Mashup Center
That is all we need to build our Data Mashup, using only 2 operators: the source and the transform.
- The source operator to pull the content of the feed
- The transform operator to take the input URL and generate an output URL using the function CONCAT. We also want the transform to output the original URL (for bilingual reader) as well as to prepare for publishing as ATOM feed.
A detail view on the Transform operator shows the creation of a new XML element named "translated_link" and the value is the concatenation I described above.
- The first part is a constant string
- The second part is a repeating element from your input feed
- The last part is a constant string
If you need to concatenate more strings, just click on the "+" button to have additional Custom fields.
3.0. Presentation Mashup
3.1. Display the feed
The created feed mashup can be displayed using the Data Viewer widget. From the feed catalog, one can "Add to Lotus Mashups" in the category "Demo".
3.2. Sample application
To create the sample application, we start with an empty page named "Translate IBM China News". Then we populate it with 3 widgets:
- The Data Viewer of the feed (named "Translate d IBM China News") we create above (widget from the Demo category).
- Two instances of the Web Site Displayer widget from the Tools category. We want to display the original chinese page and the translated page.
We then wire
- The Translated IBM China News widget to the first Web Site Displayer widget to send the original page URL and to display the page.
- The Translated IBM China News widget to the second Web Site Displayer widget to send the translated page URL and to display the page.
This wiring process creates the interactive application and completes the demo scenario. You can click on "Save" icon to save the page. When we select by clicking on the title of a feed content, both Web Site Displayer widgets will displayed the associated contents: in the original Chinese and in the translated English.
Is it that simple to create your own newspaper? We have gone through the process of creating a sample interactive application using Mashup Center. Note that a better way to start creating your own application would be to look in the mashup catalog and find/reuse someone else mashup if applicable :-)
This is the first step of building a "Daily Planet" service, an electronic newspaper that can display your company worldwide news. If you are interested, you can post a comment and I will help you.