We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

gfazioli on 07/11/08


Tagged

ajax javascript google prototypejs api translate language markup


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

gfazioli


Google AJAX API Language e Prototype.js


Published in: JavaScript 


URL: http://www.undolog.com/2008/05/13/google-ajax-api-language-e-prototypejs/

  1. /*
  2. ** @name : translate()
  3. ** @description : translate
  4. */
  5. function translate() {
  6. $$('[rel="translate"]').each(
  7. function(e) {
  8. google.language.translate(e.innerHTML, 'it', 'en',
  9. function(result) {
  10. if (result.translation) {
  11. e.innerHTML = result.translation;
  12. } else {
  13. alert( 'Translate Error!\n\n' + result.error.message );
  14. }
  15. }
  16. );
  17. }
  18. );
  19. }

Report this snippet 

You need to login to post a comment.