📜 ⬆️ ⬇️

We add ergonomics to the translator

All translators (translate.ru, translate.google.com, lingvo.ru) are good in their own way: someone has the best parser, somewhere the pictures on the buttons delight fans of true painting, someone has the fastest translation result ( possibly expensive and nimble servers), somewhere more mind invested in the development of an accessible API.

There will not be summary tables, and even “This is the best translator!” Let's leave it all to holivaram.

I use Google Translator .
')

Often, when opening the Google Translator page , I face the problem of choosing a translation language (Russian to English / English to Russian). To achieve the equivalent of a combination of the current language on the desktop and in the translator, you need to switch the keyboard layout, and then click the “switch” link. In practice, there are 2 mandatory actions for one result, but you can reduce it to one.

I solved this problem myself: I wrote a small code in user defined javascript in Opera (I have version 10.10 Beta 1833):

if (location.hostname == "translate.google.com" ) {

var onready = function () {
// textarea
document .getElementById( "source" ).addEventListener(
"keydown" ,
function ( event ) {
// SHIFT + ALT // SHIFT + CTRL
if ( event .shiftKey && event .altKey && event .keyCode == 16 || event .shiftKey && event .ctrlKey && event .keyCode == 17)
// from google code
ctr._swap();
},
false
);
};

window.addEventListener( "load" , onready, false );
}

Designed for lovers of ALT + SHIFT language switching combinations.

Works as follows:
  1. Press ALT + SHIFT, the keyboard simultaneously switches on the desktop and in the translator to the opposite language to the current one
  2. If different languages ​​are indicated on the desktop and in the translator at the same time, then we SHIFT + CTRL to synchronize the languages ​​in both programs.

And one more (last) requirement - all this will work when the text input field has the focus of the cursor.

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


All Articles