Get Chinese Romanization from Google Translate API

Posted by krubo on Stack Overflow See other posts from Stack Overflow or by krubo
Published on 2010-05-01T13:29:27Z Indexed on 2010/05/01 13:37 UTC
Read the original article Hit count: 346

The Google language translate API works cleanly to translate into Chinese:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
  google.load('language','1');
  function googletrans(text) {
    google.language.translate(text,'en','zh',function(result) {
      alert(result.translation);
    });
  }
</script>
<input onchange="googletrans(this.value);">
Example input: "Hello"
Result: "??"

My problem is I can't get the Romanization (pronunciation using English letters). This is a known issue.

Now the data is right there on translate.google.com (Example input: "Hello" Result: "Ni hao") and I can even see it by pointing my browser to:

http://translate.google.com/translate_a/t?client=t&text=hello&hl=en&sl=en&tl=zh-CN&otf=2&pc=0
Result:
{"sentences":[{"trans":"??","orig":"hello","translit":"Ni hao"}],
 "dict":[{"pos":"interjection","terms":["?"]}],"src":"en"}

But somehow when I try to get this URL with ajax it fails (XMLHttpRequest Exception 101). Is there any way to retrieve this Romanization data with ajax?

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about google