Created
August 22, 2012 07:09
-
-
Save qwtomek/3423230 to your computer and use it in GitHub Desktop.
Translate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){f="en";t="pl";w="";def=f+","+t+",";sc="www.";txt="Quick usage: [[FROM],[TO],]text\nType 'help' for a full usage review.\n\nTranslate:";help="About\nWith this bookmarklet you can type a word, sentence, or a webpage address (you should add 'www.' or 'http://' at the beginningof URL) to quickly translate it using the Google Translatr. All happens by opening a new tab in yours browser.\n\nHow to use?\nPrepend a request with 'FROM,TO,' phrase that contains language shortcuts e.g. "+def+" or use 'aa' as a FROM language, for its AUTO-recognition (you can also just skip FROM shortcut to use the AUTO one - i.e. ',pl'). By default from "+f.toUpperCase()+" to "+t.toUpperCase()+" will be translated. If you won't specify the TO language shortcut, then default "+t.toUpperCase()+" will be taken.\nRemember to separate shortcuts by any a not-a-letter character e.g. ,/; etc.\nMore detailed manual in PL at: www.pokazywarka.pl/gtrans\n\nScripted by MGeeky, v1.2";w=prompt(txt,def);url=/^(http\:\/\/|www\.)?([a-z0-9\:@\.\-_]+\.[a-z]{2,4}(?:\:[0-9]{1,5})?(?:\/.+)?)$/i;lng=/^(([a-z]{2}|auto)?[^a-z]+(?:([a-z]{2})[^a-z]+)?)/i;if(lng.test(w)){lngs=lng.exec(w);f=lngs[2];if(lngs[3]){t=lngs[3];}dl=lngs[0].length;m=w.substr(dl,w.length-dl);w=m;if(f=='aa'||!f){f='auto';}}else{m=w;}if(url.test(w)){uri=url.exec(w);if(uri[1]){sc=uri[1]}window.open("http://translate.google.com/translate?sl="+f+"&tl="+t+"&u="+sc+uri[2]+"&suggon=1");}else if(w=='help'){alert(help);}else if(w.length>1&&w!=def){window.open("http://translate.google.com/#"+f+"|"+t+"|"+encodeURI(m));}})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://translate.how/