Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

JS translation bookmarklet

I got this mostly working - the only thing that sucks is encoding of non-ascii characters like �, �, etc... I've tried escape(), but it's just stripped the offending character. Anyone know js and feel like fixing this?

javascript:langpair="fr|en";
  text=""+(window.getSelection?window.getSelection()
           :document.getselection?document.getSelection()
           :document.selection.createRange().text);
  if(!text)text=prompt("enter%20text%20to%20translate","");
  if(text!=null)void(window.open(
      "http://google.com/translate_t?langpair="+langpair+"&text="+text,
     "translate","scrollbars=1,resizablel=1,width=500,height=500"))
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed