summaryrefslogtreecommitdiffstats
path: root/util/bin/translate.google
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2014-12-27 21:43:40 +0100
committerlassulus <lass@aidsballs.de>2014-12-27 21:43:40 +0100
commitea07d18a79ccf2649568993973c21287708b0f7e (patch)
treecf4f66d1e0d1564ec4c3aa8771fb1ddf5ba69e0d /util/bin/translate.google
parent59ed4627d9439ff435b38d03ad2719cf0a55d1d0 (diff)
translate.google: add usage
Diffstat (limited to 'util/bin/translate.google')
-rwxr-xr-xutil/bin/translate.google24
1 files changed, 19 insertions, 5 deletions
diff --git a/util/bin/translate.google b/util/bin/translate.google
index 2418dc37..cb69064a 100755
--- a/util/bin/translate.google
+++ b/util/bin/translate.google
@@ -4,10 +4,24 @@ set -euf
sl=${SL:="auto"}
tl=${TL:="en"}
-text=$*
+usage(){
+ echo 'TL= targetlanguage, valid strings are in the style of "en", "pl" or "de". default "en"'
+ echo 'SL= sourcelanguage, same TL, default is auto'
+ echo 'Example: TL="de" ./translate.google whats up?'
-url="http://translate.google.com/translate_a/t?client=t&sl=$sl&tl=$tl"
+ exit 0
+}
-curl -A "Mozilla/5.0" -Ss "$url" --data-urlencode "text=$text" |
- sed 's/\[\[\[\"//' |
- cut -d \" -f 1
+translate(){
+ text=$*
+ url="http://translate.google.com/translate_a/t?client=t&sl=$sl&tl=$tl"
+ curl -A "Mozilla/5.0" -Ss "$url" --data-urlencode "text=$text" |
+ sed 's/\[\[\[\"//' |
+ cut -d \" -f 1
+}
+
+if [ $# -eq 0 ]; then
+ usage
+fi
+
+translate $*