Skip to content

Instantly share code, notes, and snippets.

@skypce
Last active December 17, 2017 03:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skypce/d04b16cc5dc0797f8f148282fcab8d78 to your computer and use it in GitHub Desktop.
Save skypce/d04b16cc5dc0797f8f148282fcab8d78 to your computer and use it in GitHub Desktop.
script dictionary and translator from google with trans
#!/usr/bin/env bash
SEL=$(xsel -o)
T="$(/usr/local/bin/trans -l es -o /tmp/output -theme=none :es "$SEL")" #echo "Translation:" "$T" >> /tmp/
ansi2html /tmp/output
#yad --html --title="Google translate and definition" --width=450 --height=300 --center --text=/tmp/output
# notify-send "$T"
#yad --info --title="Translation" --text="$T"
zenity --text-info --title="Google diccionary and translator" --filename=/tmp/output
@skypce
Copy link
Author

skypce commented Dec 16, 2017

Hi, for it works needs the follow packages:
Dependencies:
pip install ansi2html
sudo apt-get install xsel zenity
This commands are for setup trans , a awesome translator for console:
wget git.io/trans
chmod +x trans
sudo mv trans /usr/local/bin/trans
Now the last steps:
sudo chmod +x transdic
sudo mv transdic /usr/local/bin
Change the line 3 "-l es" to your language: examples: en, pl , etc.
If you are using ubuntu , go to system settings -> keyboard -> shortcuts -> custom shortcuts and add transdic and set your shortcut key.
Now when you select a piece of text and press the shortcut key, the script automatically will translate it to specified language and give you the mean of the word . Enjoy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment