Posted By

arpo on 10/15/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Google translate basics


 / Published in: JavaScript
 

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  5. <title>Google AJAX Language API - Basic Translation</title>
  6. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  7. <script type="text/javascript">
  8. //Docs
  9. //http://code.google.com/apis/ajaxlanguage/documentation/#Examples
  10.  
  11. //Language codes
  12. //http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameArray
  13. google.load("language", "1");
  14.  
  15. function initialize() {
  16. google.language.translate("Hello world", "en", "es", function(result) {
  17. if (!result.error) {
  18. var container = document.getElementById("translation");
  19. container.innerHTML = result.translation;
  20. }
  21. });
  22. }
  23. google.setOnLoadCallback(initialize);
  24.  
  25. </script>
  26. </head>
  27.  
  28. <body>
  29. <div id="translation"></div>
  30. </body>
  31. </html>

Report this snippet  

You need to login to post a comment.