Team:Sevilla/test3

From 2011.igem.org

(Difference between revisions)
Line 94: Line 94:
 +
<!--===================================TRADUCCION================================================-->
 +
 +
<script src="http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0" type="text/javascript"></script>
 +
    <script type="text/javascript">
 +
    /*
 +
    *  How to translate text.
 +
    */
 +
   
 +
    google.load("language", "1");
 +
   
 +
    function initialize() {
 +
      var content = document.getElementById('content');
 +
      // Setting the text in the div.
 +
      content.innerHTML = '<div id="text">Hola, me alegro mucho de verte.<\/div><div id="translation"/>';
 +
   
 +
      // Grabbing the text to translate
 +
      var text = document.getElementById("text").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, 'es', 'en', 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>
 +
  </body>

Revision as of 14:11, 5 April 2011

Loading...
Loading...