Skip to content

Instantly share code, notes, and snippets.

@ychaouche
Last active February 27, 2024 14:08
Show Gist options
  • Save ychaouche/2ccc158e5fc1f3c9a41518cc585bf200 to your computer and use it in GitHub Desktop.
Save ychaouche/2ccc158e5fc1f3c9a41518cc585bf200 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 10:32:01 ~ -1- $ net.translate "j'ai pas envie de me prendre la tête avec unicode"
# I don't want to bother with unicode.
# 10:32:23 ~ -1- $
while (( $# ))
do
case "$1" in
-f|--from)
from="$2"
shift 2
;;
-t|--to)
to="$2"
shift 2
;;
*)
translate="$1"
shift
;;
esac
done
url="http://translate.googleapis.com/translate_a/single?client=gtx&sl=$from&tl=$to&dt=t&q=$translate"
curl -s "$url" --data-urlencode "q=$translate" | jq -r ".[0][0][0]" -M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment