translate (388B)
1 #!/bin/sh 2 3 if [ $# -ne 2 ]; then 4 printf 'usage: translate srclang destlang\n\n' >&2 5 exit 1 6 fi 7 8 curl -s \ 9 -X POST "https://libretranslate.com/translate" \ 10 -H "accept: application/json" \ 11 -H "Content-Type: application/x-www-form-urlencoded" \ 12 -d "q=$(sed 's, ,%20,g')&source=${1}&target=${2}&api_key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" |\ 13 awk -F'"' '/translatedText/ { print $4 }'