Hacker News new | ask | show | jobs
by drfloob 5800 days ago
Nice project. I'll be putting this script on my sites for sure.

At first glance though, I didn't like that it translated the content of <pre> and <code> tags, so here's my quick fix for that.

  TranslateThis({onLoad: function(){
    // avoids <pre> and <code> tags
    var nt= function(el){el.className+=" notranslate";};
    var pres= document.getElementsByTagName('pre');
    var codes= document.getElementsByTagName('code');
    for(var i=0; i<pres.length; i++) { nt(pres[i]); }
    for(var i=0; i<codes.length; i++) { nt(codes[i]); }
  }});