Translate easily with JavaScript and the Google language API

published on March 26, 2008 by Michal
category: AJAX, Javascript, google

wow, google recently released an API for their translation services called Google language API. Thats a good news but it even gets better! The api is really easy to use and applications can be boosted within minutes. The reference can be found here

Here is a quick example of how to translate something...

JAVASCRIPT:
  1. google.language.translate('my mum is swimming', 'en', 'de', function(result) {
  2.   alert(result.translation);
  3. });

and it gets better and even easier: its possible to let the API detect the language .. so nothing you have to take care about anymore.

JAVASCRIPT:
  1. google.language.detect('Deutsch ist auch eine Sprache',
  2.  function(result) {
  3.   alert(result.language);
  4. });

Further reading: An introduction to the language API and translation tools.

Now its time to come up with some nice little tools, widgets which use this service. "a user selects a paragraph an your page, clicks a button and suddenly the text is translated into the desired language".

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...

Leave a Reply


Please surround code with [asp]..[/asp], [javascript]..[/javascript], [php]..[/php], [html]..[/html] to highlight source code within your comments.

Currently highest rated articles on webdevbros: