view bin/translatefromto @ 3368:4cc20236c6ad

<elliott> addquote <+kmc> Harry Potter and the Physical Impossibility of Death in the Mind of Someone Living
author HackBot
date Sat, 03 Aug 2013 21:13:16 +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"]'