Scripts by ArnonEilat

Translate Text

I've written a script to translate from English to Hebrew.

The target language can modify by changing the URL parameters

// Menu: Translate
// Description: Translate Text
// Author: Arnon Eilat
let { getSelectedText } = await kit("text");
const getWord = async () => {
let word = await arg("Word to Translate");
if (word === "") {
word = await getSelectedText();
}
return encodeURIComponent(word.trim());
};
const open = (url) => exec(`open "${url}"`);
onTab("Google Translate ", async () => {
const word = await getWord();
const url = `https://translate.google.com/#view=home&op=translate&sl=en&tl=iw&text=${word}`;
open(url);
});
onTab("Yandex Translate", async () => {
const word = await getWord();
const url = `https://translate.yandex.com/?lang=en-he&text=${word}`;
open(url);
});
Discuss Post