Google AJAX Language API

The “Hello, World” of the Google AJAX Language API

The easiest way to start learning about this API is to see a simple example. The following example will detect the language of the given text and then translate it to English.

<script type="text/javascript" src=""></script>
<script type="text/javascript">
google.load("language", "1");
function initialize() {
 var text = document.getElementById("text").innerHTML;
 google.language.detect(text, function(result) {
  if (!result.error && result.language) {
   google.language.translate(text, result.language, "en",
   function(result) {
    var translated = document.getElementById("translation");
    if (result.translation) {
     translated.innerHTML = result.translation;
<div id="text">你好,很高興見到你。</div>
<div id="translation"></div>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.