BabelFish Web Service

The BabelFish translation service at XMethods (http://www.xmethods.net) is a sample that can be implemented easily with a couple of text fields, a combo box, and a button. With a few lines of ActionScript code, you can put language translation functionality into a Flash movie and into your site. The BabelFish method at http://www.xmethods.net/sd/2001/BabelFishService.wsdl takes two arguments: translationmode and sourcedata.

The translationmode argument is a special code for the two languages used in the translation, as shown in Table 10-2. This data is displayed in a combo box named language_cb.

Table 10-2. Translation modes for the BabelFish remote method

From

To

translationmode

English

French

en_fr

English

German

en_de

English

Italian

en_it

English

Portuguese

en_pt

English

Spanish

en_es

French

English

fr_en

German

English

de_en

Italian

English

it_en

Portuguese

English

pt_en

Russian

English

ru_en

Spanish

English

es_en

The sourcedata argument is the text that you want translated (limited to a string of 150 characters or less). The Flash UI, shown in Figure 10-2, allows the user to type into the from_txt text field, choose a language translation from the combo box, click a button, and get the result in a text field named to_txt.

Translation interface
Figure 10-2. Translation interface

The client-side ActionScript code is shown in Example 10-4, using ...

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.