Google Translate API From The Command Line

Simple wrapper for google translate api

#!/bin/bash

if [ $# == 3 ]
then
echo "From: $1 To: $2"
lynx -dump "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$3&langpair=$1|$2"|awk -F'"' '{print $6}'

else
lynx -dump "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=|ar"|awk -F'"' '{print "From: "$10" To: ar \n"$6}';echo

lynx -dump "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=|en"|awk -F'"' '{print "From: "$10" To: en \n"$6}';echo

fi

Example:

$ ./gtranslate.sh ru en "тест"
From: ru To: en
test



coded by nessus