Google AJAX Translation API

Written by on March 21st, 2008 in Ajax News.

The game above uses the new Google AJAX Translation API that allows you to do two things via a simple JavaScript API.

Translation

If you want to take a word in one language, and translate it to another, you simply call something like this:

JAVASCRIPT:

  1.  
  2. google.language.translate(’Gato’, ‘es’, ‘en’, function(result) {
  3.   alert(result.translation);
  4. });
  5.  

Here are the languages we support.

What if you need to programatically grok which language a string is written in? You can use the detection algorythm:

JAVASCRIPT:

  1.  
  2. google.language.detect(’Questa linea di rilevare che questa è la lingua.’,
  3.  function(result) {
  4.   alert(result.language);
  5. });
  6.  

The detector doesn’t just tell you the result, it also lets you know how reliable and confident it is.

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/255657826/google-ajax-translation-api

Comments are closed.



Site Navigation