×
Namespaces

Variants
Actions

Google Translate API in WRT

From Nokia Developer Wiki
Jump to: navigation, search

Simple Symbian Web Runtime app 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.

Article Metadata
Code Example
Installation file: GoogleTranslator0.1.wgz
Article
Created: wmseto (09 Apr 2009)
Last edited: hamishwillee (10 Oct 2012)

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>
This page was last modified on 10 October 2012, at 06:00.
38 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×