* Jonas Meurer <[EMAIL PROTECTED]> [2004-10-01 19:08]: > i raised the severity to important as this is an annoying but and it > renders translate more or less unusable for users with utf-8 locales.
Here is a patch for this bug. This converts input to Latin1 and output to UTF-8 if we're in a UTF-8 locale. Ideally, the dictionary should be in UTF-8 and we would then convert the input to UTF-8 if it isn't already, but I'll have to talk to the ding maintainer about this. You have to modify /etc/translate.conf and replace LANG with LANGUAGE. --- translate.orig 2005-04-15 00:05:08.299641456 +0100 +++ translate 2005-04-15 00:06:48.238448448 +0100 @@ -26,7 +26,7 @@ GLOBDIR=/usr/share/trans GLOBALCONF=/etc/translate.conf LOCALCONF=$LOCDIR/translate.conf -LANG=de-en +LANGUAGE=de-en WHOLEWORD=false DONT_ASK=false INVERS=false @@ -76,6 +76,15 @@ fi } +display () +{ + if [ $UTF8 ]; then + echo "$1" | iconv -f ISO-8859-1 -t UTF-8 + else + echo "$1" + fi +} + # If there is no $LOCDIR we should create one if [ ! -d $LOCDIR ] then @@ -104,7 +113,7 @@ -h) usage; exit 0 ;; -n) DONT_ASK=true; shift;; -i) invert_lang; shift;; - -l) LANG=$2; shift; shift;; + -l) LANGUAGE=$2; shift; shift;; --) shift; break;; esac done @@ -115,8 +124,8 @@ fi # Finally we should know what language to use -GLOBDIC=$GLOBDIR/$LANG -LOCDIC=$LOCDIR/$LANG +GLOBDIC=$GLOBDIR/$LANGUAGE +LOCDIC=$LOCDIR/$LANGUAGE # Is there already a global dictionary for these languages # or should we rely on our own, private one? @@ -139,6 +148,11 @@ fi fi +if locale 2>&1 | grep -E -q "UTF-8?$"; then + UTF8=1 +fi +[ $UTF8 ] && DIC=$(echo "$DIC" | iconv -f UTF-8 -t ISO-8859-1) +LANG=en_US # now get the real work done if @@ -148,19 +162,20 @@ if [ $INVERS = false ] then - egrep -ihs "$*".*' :: ' $DIC + result=$(egrep -ihs "$*".*' :: ' $DIC) else - egrep -ihs ' :: '.*"$*" $DIC + result=$(egrep -ihs ' :: '.*"$*" $DIC) fi else if [ $INVERS = false ] then - egrep -ihs '\b'"$*"'\b'.*' :: ' $DIC + result=$(egrep -ihs '\b'"$*"'\b'.*' :: ' $DIC) else - egrep -ihs ' :: '.*'\b'"$*"'\b' $DIC + result=$(egrep -ihs ' :: '.*'\b'"$*"'\b' $DIC) fi fi + display "$result" then # Done exit 0 @@ -179,6 +194,7 @@ else # We've got a new entry if [ $INVERS = false ] + # FIXME: handle UTF-8 (?) then echo "$* :: $NEW_ENTRY" >> $LOCDIC else -- Martin Michlmayr http://www.cyrius.com/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]