Skip to content

Instantly share code, notes, and snippets.

@LinArcX
Created July 4, 2019 18:24
Show Gist options
  • Select an option

  • Save LinArcX/156e0f74f47d21d683c691ee2816b5b9 to your computer and use it in GitHub Desktop.

Select an option

Save LinArcX/156e0f74f47d21d683c691ee2816b5b9 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
####displays the translation
text="$@"
if [[ "$text" =~ ^[a-z] ]];then
translate="$(wget -U "Mozilla/5.0" -qO - "http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=fa&dt=t&q=$(echo $text | sed "s/[\"'<>]//g")" | sed "s/,,,0]],,.*//g" | awk -F'"' '{print $2, $6}')"
else
translate="$(wget -U "Mozilla/5.0" -qO - "http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dt=t&q=$(echo $text | sed "s/[\"'<>]//g")" | sed "s/,,,0]],,.*//g" | awk -F'"' '{print $2, $6}')"
fi
echo "$translate"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment