Skip to content

Instantly share code, notes, and snippets.

@vmxdev
Created July 18, 2015 12:32
Show Gist options
  • Select an option

  • Save vmxdev/a9952fa75b3d6bd0b558 to your computer and use it in GitHub Desktop.

Select an option

Save vmxdev/a9952fa75b3d6bd0b558 to your computer and use it in GitHub Desktop.
translate to qulinxao
#!/bin/bash
USAGE="Usage:
$0 \"так говорил кулинксао\"
"
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
fi
FROM_LNG='ru'
TO_LNG='zh-TW'
QUERY=$*
UA="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803"
URL="http://translate.google.com/translate_a/t?client=t&hl=en&sl=$FROM_LNG&tl=$TO_LNG&otf=2&multires=1&ssel=0&tsel=0&sc=1"
CH=`curl --data-urlencode "text=$QUERY" -A $UA -s -g -4 $URL | sed 's/\[\[\["\([^"]*\).*/\1/'`
URL="http://translate.google.com/translate_a/t?client=t&hl=en&sl=$TO_LNG&tl=$FROM_LNG&otf=2&multires=1&ssel=0&tsel=0&sc=1"
RU=`curl --data-urlencode "text=$CH" -A $UA -s -g -4 $URL | sed 's/\[\[\["\([^"]*\).*/\1/'`
echo $RU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment