leo

English - German Translator for the console. It uses dict.leo.org as database which is normally only available via http-browser.

leo consists only of a sigle file. You can copy it and put it into your /usr/local/bin dir:

#!/bin/bash
# Cvs:     $Id: leo,v 1.3 2004/11/12 14:27:34 becki Exp $
# Author:  Stefan Beckert ( http://becki.skiclub-mitwitz.de/ )
# License: Public Domain
# Description:
#   see usage

# SETTINGS
url='http://dict.leo.org/?search='
pattern='Composed Entries|Direct Matches|^[[:space:]]*Verbs and Verb|^[[:space:]]*Examples'
lines=6
# END SETTINGS


#scna=$(basename $0)
#usage="Usage:\n\
#  $scna expression - to get the translation for 'expression'"

function query {
  expr="$(echo $* | tr ' ' '+')";
  #echo $expr
  lynx -dump -nolist $url$expr | grep -E --after-context=$lines "$pattern"
  if [ $? -ne 0 ]; then
	lynx $url$expr
  fi
}


if [ $# -lt 1 ]; then # Test number of command line arguments: loop mode
  while
	read -p 'Search term (English or German): ' inp
	test "$inp"
  do
	clear
	query $inp
	echo
  done
else # single run mode
  query $*
fi