this is just a very simple hackeable python script that translates selected text (or from clipboard) and show the result as a notification. It works using xsel, translate-shell and libnotify.
- translate-shell
- libnotify
- xsel
place the script and gt_icon wherever you want and add execute permission. set up a trigger: I use a keyboard short cut to trigger the script
-h
: display help-tr, --translate
: format lang_src:lang_dest. defaulten:es
. see translate-shell for more info-t --timeout
: notification timeout in milliseconds. default5000
-p --params
: translate-shell coma separated additional params. defaultb
(brief translation)
examples:
xtranslate -p "b,sp" // brief translate and **speak** the input text
xtranslate -tr ":es" // auto detect source language and translate to spanish"
again, see translate-shell docs to get more info to play with.
- language support: see translate-shell
- translate any selected text or text from the clipboard. please take in account the limitations of translate-shell.
- open in browser: opens translate.google.com. The url arguments are source and destination language and the text to translate. If source is empty (:es) it sends auto param for autodetection mode. see google translate query docs for customizations
just do python xtranslate.py
or open the file in some IDE like pycharm, vs code with python debugger.
- support for other translators availables in translate-shell
- make arch linux package
- handle errors and limitations