Adding DeepL translator to kate-script

b606 besoa606 at gmail.com
Sat Aug 18 10:01:12 BST 2018


Hi,

I am trying to integrate the DeepL translator into kate tools menu through a 
script command.  https://github.com/vsetka/deepl-translator has made DeepL 
available as a command line utility and also in javascript (see example.js 
provided there).

I am not proficient at all in javascript and have trouble to use the require() 
function in order to be able to call the translation functions of deepl. 
I pushed my work on https://github.com/b606/katescript-deepL but it is not 
already functional.

So far my script is installed in ~/.local/share/katepart5/script/commands/
The command "Translate Selected Text" appears in the menu and a fake 
translation function correctly modify the text in place.

Then I tried various things in order to get deepl functions (all resulting in 
SyntaxError: ParseError at the require() directive line 41):

- symbolic link of the whole vsetka folder in ~/.local/share/katepart5/script/
commands/ or in ~/.local/share/katepart5/script/libraries/ and trying 
require(deepl-translator/index.js) or require(deepl-translator/src/deepl-
translator.js)
- symbolic links to the individual files of vsetka in the same folders

After reading many things about require(), I concluded that I need a kate-
script guru to solve this, if it is ever possible to do :-)

Best regards

-----
system: debian stretch with stretch-backports activated
apt-cache policy nodejs kate katepart
nodejs:
  Installé : 8.11.1~dfsg-2~bpo9+1
 *** 8.11.1~dfsg-2~bpo9+1 100
        100 http://deb.debian.org/debian stretch-backports/main amd64 Packages
kate:
  Installé : 4:16.08.3-1
 *** 4:16.08.3-1 500
        500 http://deb.debian.org/debian stable/main amd64 Packages
katepart:
  Installé : 4:4.14.3-4
 *** 4:4.14.3-4 500
        500 http://deb.debian.org/debian stable/main amd64 Packages




More information about the KWrite-Devel mailing list