google translate

A little shell interface to google translate:

#!/bin/bash
# shell interface to google translate

[ $1 ] || exit

FROM="en"
TO="ru"

for x;do case $x in
 -f*)FROM=${x#-f};;
 -t*)TO=${x#-t};;
 *)TXT="$TXT$x ";;
esac;shift;done

TXT=${TXT// /%20}

URL="http://ajax.googleapis.com/ajax/services/language/translate"
QRY="?v=1.0&q=$TXT&langpair=$FROM%7C$TO"

curl -s -e "$(hostname)" $URL$QRY | awk -F\" '$4 == "translatedText" {print $6}'

It translates English to Russian by default, and you can override FROM and TO with -fFROM and -tTO