Skip to content

Instantly share code, notes, and snippets.

@pochemuto
Created January 28, 2015 12:23
Show Gist options
  • Save pochemuto/ee142fcacd6fdaa9bbc6 to your computer and use it in GitHub Desktop.
Save pochemuto/ee142fcacd6fdaa9bbc6 to your computer and use it in GitHub Desktop.
translate string in terminal
#!/bin/bash
query=$@
cyrillicLetters="АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯяЁё"
if [[ $query =~ .*[$cyrillicLetters].* ]]
then
lang='ru-en'
else
lang='en-ru'
fi
curl "http://translate.yandex.net/tr.json/translate?lang=${lang}&text=${query}" -s | sed -e 's/^"//' -e 's/"$//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment