I am trying to define a simple function to be used for translating some user-defined text from English to Danish
I am trying to reuse the code I found as an example on the Google Playgrund, I have tried to solve this task, but I could not do it. Could anyone help? below the code You find it in action on this webpage http://serate-italiane.dk/translate.php Thanks in advance Gino <!-- copyright (c) 2009 Google inc. You are free to copy and use this sample. License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license --> <!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> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google AJAX Search API Sample</title> <script src="http://www.google.com/jsapi?key=<key> "></script> <script type="text/javascript"> /* * How to translate text. */ google.load("language", "1"); function initialize() { // text should contain the text to be translated, inserted by the user in // the input box identified by id: input_text var frase = 'it has to be user defined'; var content = document.getElementById('content'); // Setting the text in the div. content.innerHTML = '<div id="text">'+ frase + '.<\/div><div id="translation"/>'; // Grabbing the text to translate var text = document.getElementById("content").innerHTML; // Translate from Spanish to English, and have the callback of the request // put the resulting translation in the "translation" div. // Note: by putting in an empty string for the source language ('es') then the translation // will auto-detect the source language. google.language.translate(text, 'en', 'da', function(result) { var translated = document.getElementById("translation"); if (result.translation) { translated.innerHTML = result.translation; } }); } google.setOnLoadCallback(initialize); </script> </head> <body style="font-family: Arial;border: 0 none;"> <div id="content">Loading...</div> <p>Translation from English to Danish: <b id='translate'></b> </p> <input type='text' id='input_text' value='Enter Text Here' /> <input type='button' onclick='function_to_be_defined()' value='Translate'/> </body> </html> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-AJAX-Search-API?hl=en -~----------~----~----~----~------~----~------~--~---
