You Are Here:

Community: Wiki

This page was last modified on 9 April 2009, at 17:52.

Google Translate API in WRT

From Forum Nokia Wiki



Overview

Simple S60 WRT widget that uses Google Translate API to detect the source language and translate to target language. You can download the WRT widget itself, rename the extension from .wgz to .zip. Unzip file file and you will have the source code.

Download link here: [1]

Source file

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Translator</title>
<meta name="generator" content="BBEdit 8.6" />
<script src="main.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
 
google.load("language", "1");
 
function initialize() {
var text = document.getElementById("text").value;
var tlang = document.getElementById("tlang").value
google.language.detect(text, function(result) {
if (!result.error && result.language) {
google.language.translate(text, result.language, tlang,
function(result) {
var translated = document.getElementById("translation");
if (result.translation) {
translated.value = result.translation;
}
});
}
});
}
</script>
</head>
<body>
<body>
Auto detect source language and translate to:<br/>
<select id="tlang">
<option value="zh-TW">Chinese Trad</option>
<option value="zh-CN">Chinese Simpl</option>
<option value="en">English</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="pt">Portuguese</option>
<option value="es">Spanish</option>
</select><br/>
<textarea id="text" name="query" height="100px">Enter string here</textarea> <BUTTON TYPE=BUTTON onClick="initialize()">
<I>GO</I></BUTTON><br/>
<textarea id="translation" name="results" height="100px">Results</textarea><br/>
Copy from the above text box and paste the text where ever. If there is an update, it will be here: <a href="http://www.waiseto.com/2009/01/simple-google-translator-widget-for-s60.html">link</a> Enjoy W. Seto
 
</body>
</html>

info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/NOKIA_COM_1/DTDs/plist-1.0.dtd">
<plist version="1.0">
<dict>
<key>DisplayName</key>
<string>Google translator</string>
<key>Identifier</key>
<string>com.nokia.widgets.googletranslator</string>
<key>Version</key>
<string>1.0</string>
<key>MainHTML</key>
<string>index.html</string>
<key>AllowNetworkAccess</key>
<true/>
</dict>
</plist>

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia