#!/bin/sh # # translate.sh (C) 2003 Malte J. Wetz # # Windows-User may know the Babylon Translator. This is basically # the same for linux, only better :) # # This script takes the current content of the X-Selection # (the "clipboard") and tries to translate it. # The translation is then displayed in a message box. # # The idea behind this is that you can use a hotkey manager # like xbindkeys, LinEAK or hotkeys to call translate.sh. You # can then translate the word currently selected in X11 # automagically. # # Programs required: #   o xsel  #   o dict command line client  #   o Xdialog  #   o or, instead of Xdialog: kdialog (part of KDE) TMPFILE=/tmp/translate.$$.tmp #DIALOG=Xdialog #OPTIONS="--under-mouse" DIALOG=kdialog # Get the selected text WORD=`xsel -p` [ -z "$WORD" ] && { $DIALOG $OPTIONS --title "Error" --msgbox "You have not selected any text." 6 30 exit 1 } #Traslate it! egrep -h /usr/share/trans/de-en -e $WORD > $TMPFILE # recode temp file from utf-8 to latin1 #recode -f utf-8..latin1 $TMPFILE # Show translation #Xdialog --textbox "$TMPFILE" 20 70 $DIALOG $OPTIONS --title "Translation" --textbox "$TMPFILE" 550 250 # remove the temp file rm -f "$TMPFILE"