#!/bin/bash
#Simple script to automaticaly translate highligted text
#Dependencies: yad e trans
#You can instal "trans" via synaptic or terminal with this command: sudo apt-get install translate-shell

## Testing for dependecies and, in s debian distro, try to install it if user so selects
	if ! [ -x "$(command -v trans)" ]; then
	yad --title=$"Trans" --window-icon="clipit-trayicon" --center --text=$"Install translate-shell (+/- 400kb)? " --button=$"OK":1 --button=$"x":2	
	 foo=$?
		if [[ $foo -eq 1 ]]; then x-terminal-emulator -T $"FT10" -e /bin/bash -c "gksu 'apt install -y translate-shell'"
		traduzir
		fi
	  exit 1
	fi
	
#texto_original=$(xclip -selection c -o)
texto_original=$(xclip -out)
texto_traduzido=$(trans  -b -show-alternatives n "$texto_original")
yad  --title="Trans" --window-icon="clipit-trayicon" --fixed --width=700 --height=480 --center --form --field=":TXT" "$texto_traduzido" --button="Ok"

