Advertisement
Guest User

mydict

a guest
Jan 12th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.29 KB | None | 0 0
  1.         mydict () {
  2.             # Show usage
  3.             if [ $# = 1 ]; then
  4.                 if [[ $1 == -h || $1 == "--help" ]]; then
  5.                     echo "Usage: add any numbers of words as parameters"
  6.                     echo "Or:    just run mydict and input any numbers of words"
  7.                     echo "  It will translate every words to Chinese and pronounce it"
  8.                     echo "  You need have dict installed"
  9.                     return
  10.                 fi
  11.             fi
  12.             # If any parameters, translate them and pronounce them first
  13.             for param in $@; do
  14.                 echo "-----------------------------------------------------"
  15.                 dict $param
  16.                 mplayer http://dict.youdao.com/dictvoice\?audio\=$param > /dev/null 2>&1
  17.                 return
  18.             done
  19.             # Translate every word user input which separated by spaces
  20.             while true; do
  21.                 echo -n ">>>"
  22.                 read words
  23.                 for word in $(echo $words); do
  24.                     echo "-----------------------------------------------------"
  25.                     dict $word
  26.                     mplayer http://dict.youdao.com/dictvoice\?audio\=$word   > /dev/null 2>&1
  27.                 done
  28.             done
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement