I hope someone can help!! I've been beating my head against the wall trying to figure this out for a while now.
I have an admin site for an e-commerce site, that allows the admin to do various things including adding new products and text. Currently when new text is added, it has to be manually translated into multiple languages and cut and pasted into the appropriate directory. A pain in the neck. So I have been attempting to develop a translate button, that when clicked will retrieve a file from the server, send the data to google, translate it, and then update the server with the translated text. I have all of it working but one small piece. The onclick of the 'Translate' button triggers the translateMe function, shown in part below. I have PHP code that loops thru the file until it finds the line that needs translated, and then sends that to google. The result is placed in the innerHTML of the div "translation". Here's where my problem lies. Everything works up until I try to access the div "translation" to return the translated data to my PHP code to write the file to the server. Everything I do just tells me the div is null, even though I can see the text (including translations) on my screen. I'm not sure if this is because I still see the message 'Transferring Data from www. . .. ." in the status bar of the browser. I tried adding jquery to check for the ready status, but that only checks for the initial page load, not the transferring of data from Google. Please help!!! <script type="text/javascript" src="http://jqueryui.com/latest/ jquery-1.3.2.js"></script> <script type="text/javascript" src="http://www.google.com/jsapi"></ script> <script type="text/javascript"> google.load("language", "1"); function translateMe(tlang){ var translated = document.getElementById("translation"); translated.innerHTML = " "; <?php for($count=1;$count<=count($file_array);$count++){ $text = ($count . " " . str_replace('"','~', (trim ($file_array[$count])))); if (strpos($file_array[$count],' define(') != false) { // translate text if it contains 'define(' ?> google.language.translate("<?php echo ($text);?>", 'en', tlang, function(result) { if (result.translation) { translated.innerHTML += result.translation + "\n"; } }); <?php } else { // move remaining text 'as is' to transText ?> translated.innerHTML += "<?php echo ($text)?>" + "\n"; <?php echo "\n"; } } ?> } </script> <body> <div id="translation"></div> </body> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
