Last active
January 17, 2016 17:31
-
-
Save hanksudo/bc873267d85b00d79baf to your computer and use it in GitHub Desktop.
Google Translate API shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
usage () | |
{ | |
echo 'Usage :' | |
echo "\t$0 Text" | |
exit | |
} | |
if [ "$#" -ne 1 ] | |
then | |
usage | |
fi | |
# Set your API KEY here. | |
APIKEY="" | |
declare -a arr=("zh-tw" "ja") | |
for LANG in "${arr[@]}" | |
do | |
RESULT=`curl -s https://www.googleapis.com/language/translate/v2?q=$1\&target=zh-tw\&key=$APIKEY 2>/dev/null | sed -n -e '/"translatedText":/ s/^.*"\(.*\)".*/\1/p'` | |
echo $LANG: $RESULT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment