annotate bin/translatefromto @ 0:e037173e0012

Initial import.
author HackBot
date Thu, 16 Feb 2012 19:42:32 +0000
parents
children 30212f437ffe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e037173e0012 Initial import.
HackBot
parents:
diff changeset
1 #!/bin/bash
e037173e0012 Initial import.
HackBot
parents:
diff changeset
2 TEXT="$1"
e037173e0012 Initial import.
HackBot
parents:
diff changeset
3 FROM=`echo "$TEXT" | sed 's/ .*$//'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
4 TEXT=`echo "$TEXT" | sed 's/^[^ ]* //'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
5 TO=`echo "$TEXT" | sed 's/ .*$//'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
6 TEXT=`echo "$TEXT" | sed 's/^[^ ]* //'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
7 if [ "$FROM" = "auto" ] ; then FROM="" ; fi
e037173e0012 Initial import.
HackBot
parents:
diff changeset
8
e037173e0012 Initial import.
HackBot
parents:
diff changeset
9 curl -e http://codu.org/ http://ajax.googleapis.com/ajax/services/language/translate \
e037173e0012 Initial import.
HackBot
parents:
diff changeset
10 --data-urlencode v=1.0 \
e037173e0012 Initial import.
HackBot
parents:
diff changeset
11 --data-urlencode q="$TEXT" \
e037173e0012 Initial import.
HackBot
parents:
diff changeset
12 --data-urlencode langpair="$FROM"'|'"$TO" 2> /dev/null |
e037173e0012 Initial import.
HackBot
parents:
diff changeset
13 json 'data["responseData"]["translatedText"]'