📜 ⬆️ ⬇️

Highlighted text translator for Google Chrome

I think Habrovchanam using Google Chrome should be interesting:
When transferring from firefox to chrome, I had a question about transferring several plug-ins, while in chrome plug-ins are in the conception stage. In particular, I was interested in how to find an analogue of the Unofficial plug-in Google Translate Firefox extension , which can translate a selected phrase in a small window.
There was a small solution - bookmarklet. Highlighting the text and clicking on the bookmalet can get its translation in a new, pop-up window of small size :)
Add the text below to the bookmark (unfortunately, if you add it as a link, you won’t be able to transfer it to the bookmarks, you had to add it as a code):
javascript:function x(){loc=location.href; lang='ru'; flag=true;text = ''; if (window.getSelection) { text= window.getSelection(); } else if (document.getSelection) { text = document.getSelection(); } else if (document.selection) { text = document.selection.createRange().text;}}function y(){if((text=='')){location='http://translate.google.ru/translate?u='%20+%20encodeURIComponent(loc)+'&sl=auto&tl='+lang;}} function z(){if ((text!='')){ var res=window.open('http://translate.google.ru/translate_t?text='+text+'&sl=auto&tl='+ lang ,'gTranslate_popup','left='+((window.screenX||window.screenLeft)+10)+',top='+((window.screenY||window.screenTop)+10)+',height=500px,width=950px,resizable=1,scrollbars=1');window.setTimeout(function(){ res.focus()},300)}} x(); y(); z();

If on points, then:
1. Select this code.
2. Create a bookmark, add this code to the url.
Check: select the text, click on the bookmark, if everything is done correctly, a window will appear with the translation of the selected text.

You can also translate pages with the translation service from Promt with one click, for this use the following bookmarklets:

Promt-General:
javascript:location.href="http://www.translate.ru/url/tran_url.asp?lang=ru&direction=er&template=General&cp1=NO&cp2=NO&psubmit2.x=41&psubmit2.y=14&url="+document.location.href

Promt Internet:
javascript:location.href="http://www.translate.ru/url/tran_url.asp?lang=ru&direction=er&template=Internet&cp1=NO&cp2=NO&psubmit2.x=40&psubmit2.y=11&url="+document.location.href

Promt-software:
javascript:location.href="http://www.translate.ru/url/tran_url.asp?lang=ru&direction=er&template=Software&cp1=NO&cp2=NO&psubmit2.x=95&psubmit2.y=19&url="+document.location.href

Offtopic: found jabber er@translate.jrudevels.org - translator promt. Translates no more than 200 characters, similarly to m.translate.ru

')

Source: https://habr.com/ru/post/62538/


All Articles