Archived:Using Bing translator API in Flash Lite

From Nokia Developer Wiki
Jump to: navigation, search



Article Metadata
Code ExampleArticle
Created: manikantan (23 Dec 2009)
Last edited: hamishwillee (14 May 2013)



This article describes the usage of Bing Translation API in your Flash Lite client. This application can translate in various international languages, using the Bing translation engine (version 2.2) provided by Microsoft. Bing Translator (previously Live Search Translator and Windows Live Translator) is a service provided by Microsoft as part of its Bing services which allow users to translate texts or entire web pages into different languages.

Tip.pngTip: The author recommends reading google translator API article before this article. Both articles share common characteristics, UI design.


Here are the keys steps -

1. Request a Bing API Key from Bing site. Like any other API key, it is used to track the request made for a service or in simple terms, it is an identifier of the requesting party to Microsoft.

2. Understand the various types of communication methods available, for communicating with the server. This can be found at the site http://msdn.microsoft.com/en-us/library/dd877872.aspx They are of three major types - JSON, XML, SOAP.

3. Process the result obtained.

Making the Request

I have already discussed how a JSON based client has to be implemented in Flash Lite in google translator api article. SOAP type of web-services are simple to implement with the webserviceconnector component. In this article, we focus on how XML implementation is done. Before beginning to code the XML usage of the API, we need to understand the request is made as a query and the return is of XML type.

In order to request for data in the XML mode, you can use the loadvars() function in Flash


Here, toTranslate is the sentence to be translated ( after escape() ), src_lang and dest_lang are source and target languages respectively.

Result Processing

In addition after some testing I found that some further processing of text was needed after unescape(). Quotation marks, apostraphe characters has some trouble in getting rendered. Hence I had to handle it myself as follows.

function process(ip:String):String {
while (ip.indexOf("&apos;") != -1) {
var arr:Array = ip.split("&apos;");
ip = arr.join("'");
while (ip.indexOf("&quot;") != -1) {
var arr:Array = ip.split("&quot;");
ip = arr.join("\"");
return ip;

In order to handle the receipt of data, you will need to write a onData function that processes the incoming XML data structure. Parsing an XML tree is again quite simple and to conclude creating a translation engine client is quite simple in Flash Lite.



Note.pngNote: There is a need for specific fonts on the device for certain fonts to be rendered. For example for text in Chinese, Chinese font has to be supported on the target device. The screen-shots shown are taken from Adobe device central CS3 on a Nokia 5800. The client is built for touch devices. This article is a sequel to the Google Translation API article and certain steps like creating an language -lookup table, escape() and unescape() of the strings are common to both cases and are not discussed in this article.


The associated FLA is attached in this file. Media:Bing translate.zip


--manikantan 19:49, 23 December 2009 (UTC)

This page was last modified on 14 May 2013, at 09:15.
57 page views in the last 30 days.

Was this page helpful?



Thank you!

We appreciate your feedback.