translate(){ wget -qO-
"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=$2|${3:-en}"
| sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; }
2010-03-08 03:15:48
Usage:translate <phrase> <source-language> <output-language>
Example:translate hello en es
See this for a list of language codes: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
translate() {
lng1="$1";lng2="$2";shift;shift; wget -qO-
"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=${@//
/+}&langpair=$lng1|$lng2" | sed
's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; }
allow multiword translations
cmd=$( wget -qO-
"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=$2|${3:-en}"
| sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; ); echo "$cmd"
2010-03-13 01:09:00
translate <phrase> <source-language> <output-language>
works from command line
wget -U "Mozilla/5.0" -qO -
"http://translate.google.com/translate_a/t?client=t&text=translation+example&sl=auto&tl=fr"
| sed 's/\[\[\[\"//' | cut -d \" -f 1
tl = target language (en, fr, de, hu, ...);
you can leave sl parameter as-is (autodetection works fine)
substitute "example" with desired string;
you can leave sl parameter as-is (autodetection works fine)
curl -s -A "Mozilla"
"http://translate.google.com.br/translate_a/t?client=t&text=Hi+world&hl=pt-BR&sl=en&tl=pt&multires=1&ssel=0&tsel=0&sc=1"
| awk -F'"' '{print $2}'
Translates a string from English to Portuguese by using google translator web service. Source: http://www.commandlinefu.com