Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Text Translation with Javascript
Old 12-04-2008, 02:56 PM Text Translation with Javascript
Hoosier_Buddy's Avatar
Extreme Talker

Posts: 204
Name: Justin Allen
Location: Corydon, IN
Trades: 0
would like to know the best way to translate text,

I found a script somewhere on a site & I've been messin with it, but im runnin into problems...
------------
<script src="
http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("language", "1");

function spanish() {
google.language.translate(document.getElementById( "translate").innerHTML , "en", "es", function(result) {
if (!result.error) {
var container = document.getElementById("translate");
container.innerHTML = result.translation;}});}

function german() {
google.language.translate(document.getElementById( "translate").innerHTML , "en", "de", function(result) {
if (!result.error) {
var container = document.getElementById("translate");
container.innerHTML = result.translation;}});}

function french() {
google.language.translate(document.getElementById( "translate").innerHTML , "en", "fr", function(result) {
if (!result.error) {
var container = document.getElementById("translate");
container.innerHTML = result.translation;}});}
</script>

<input type="button" value="spanish" onClick="spanish()">
<input type="button" value="german" onClick="german()">
<input type="button" value="french" onClick="french()">

<div id="translate">This text will be translated.</div>
------------
it's probably not the best way of doing this, cause for one: when u translate from english to (lets say) spanish / then u click german / that's where the txt gets out of wack...do you see what i mean? does anyone know how to code it where the user can select a language to translate from and then select a language to translate to...then a input button to run the function...any help would be very much appreciated...
__________________
Justin Allen
WebTeam

Please login or register to view this content. Registration is FREE

Last edited by Hoosier_Buddy; 12-04-2008 at 03:12 PM..
Hoosier_Buddy is offline
Reply With Quote
View Public Profile Visit Hoosier_Buddy's homepage!
 
 
Register now for full access!
Reply     « Reply to Text Translation with Javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08495 seconds with 12 queries