view bin/translatefromto @ 2267:efe1516cbcdf

<elliott> addquote * ais523 challenges the americans here to remember who lost in the most recent UK general election <Phantom_Hoover> ais523, the lib dems
author HackBot
date Tue, 26 Feb 2013 18:43:02 +0000
parents e037173e0012
children 30212f437ffe
line wrap: on
line source

#!/bin/bash
TEXT="$1"
FROM=`echo "$TEXT" | sed 's/ .*$//'`
TEXT=`echo "$TEXT" | sed 's/^[^ ]* //'`
TO=`echo "$TEXT" | sed 's/ .*$//'`
TEXT=`echo "$TEXT" | sed 's/^[^ ]* //'`
if [ "$FROM" = "auto" ] ; then FROM="" ; fi

curl -e http://codu.org/ http://ajax.googleapis.com/ajax/services/language/translate \
         --data-urlencode v=1.0 \
         --data-urlencode q="$TEXT" \
         --data-urlencode langpair="$FROM"'|'"$TO" 2> /dev/null |
         json 'data["responseData"]["translatedText"]'