Translate easily with JavaScript and the Google language API

By | March 26

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
< view plain text >
  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
< view plain text >
  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”.