From 7bb224ccdb90e18bcd16a9df1caad9edf0a2c847 Mon Sep 17 00:00:00 2001 From: Robin Johnson Date: Sat, 10 Aug 2002 04:19:12 +0000 Subject: [PATCH] Added language scripts --- ChangeLog | 4 +++ lang/check_lang.sh | 59 ++++++++++++++++++++++++++++++++++++++ lang/sort_lang.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100755 lang/check_lang.sh create mode 100755 lang/sort_lang.sh diff --git a/ChangeLog b/ChangeLog index 85019d52b..bacc934eb 100755 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,10 @@ $Source$ * lang/finnish: update, thanks to Visa Kopu (visa) * lang/indonesion: update, thanks to Rachim Tamsjadi (tamsy) * lang/italian: update, thanks to Pietro Danesi (danone) + * lang/sort_lang.sh: + - New script to neaten all language files + * lang/check_lang.sh: + - New script to check language files for consistancy 2002-08-08 Robin Johnson * Documentation.html: diff --git a/lang/check_lang.sh b/lang/check_lang.sh new file mode 100755 index 000000000..595af25ac --- /dev/null +++ b/lang/check_lang.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# $Id$ +## +# Shell script to check that all language files are syncronized +# Catches duplicate/missing strings +# +# Robin Johnson +# August 9, 2002 +## +MASTER="english-iso-8859-1.inc.php3" +TMPDIR="tmp-check" +FILEPAT="*.inc.php3" +STRINGSTRING='^[[:space:]]*\$[[:alnum:]_]*[[:blank:]]* =' + +rm -rf $TMPDIR +mkdir -p $TMPDIR + +#Build the list of variables in each file +#Note the special case to strip out allow_recoding +echo -e "Building data" +for f in $FILEPAT; +do + + egrep "$STRINGSTRING" $f | \ + grep -v 'allow_recoding' | \ + cut -d= -f1 | cut -d'$' -f2 | \ + sort > $TMPDIR/$f +done; + +#Build the diff files used for checking +#And if there are no differences, delete the empty files +echo -e "Comparing data" +for f in $FILEPAT; +do + diff -u $TMPDIR/$MASTER $TMPDIR/$f >$TMPDIR/$f.diff + if [ ! $MASTER == $f ]; then + if [ `wc -l $TMPDIR/$f.diff | cut -c-8|xargs` == "0" ] ; + then + rm -f $TMPDIR/$f.diff $TMPDIR/$f + fi; + fi; +done; + +#build the nice difference table +echo -e "Differences" +diffstat -f 0 $TMPDIR/*.diff >$TMPDIR/diffstat 2>/dev/null +head -n $((`wc -l <$TMPDIR/diffstat` - 1)) $TMPDIR/diffstat > $TMPDIR/diffstat.res +echo -e "Dupe\tMiss\tFilename" +cat $TMPDIR/diffstat.res | \ +while read filename sep change add plus sub minus edits exclaim; +do + echo -e "$add\t$sub\t$filename"; +done; + +echo +echo "Dupe = Duplicate Variables" +echo "Miss = Missing Variables" +echo "For exact problem listings, look in the $TMPDIR/ directory" +echo "Please remember to remove '$TMPDIR/' once you are done" diff --git a/lang/sort_lang.sh b/lang/sort_lang.sh new file mode 100755 index 000000000..98858a54e --- /dev/null +++ b/lang/sort_lang.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# $Id$ +## +# Shell script to make each language file neat and tidy +# +# Robin Johnson +# August 9, 2002 +## + +function sortlang() +{ + f=$1 + targetdir=tmp-$f + mkdir -p $targetdir + + TRANSLATIONSTRING='//.*translate.*$' + STRINGSTRING='^[[:space:]]*\$str[[:alnum:]_]*' + WHITESPACE='^[[:blank:]]*$' + STRINGORDER="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" + + echo -n "Extracting:" + echo -n " head" + egrep -i -v $TRANSLATIONSTRING $f | \ + egrep -v $STRINGSTRING | \ + sed 's/?>//g;s/>$targetdir/head + + echo -n " strings" + egrep -i -v $TRANSLATIONSTRING $f | \ + egrep $STRINGSTRING | \ + egrep -v $WHITESPACE >$targetdir/tmp-tosort + + echo -n " pending_translations" + egrep -i $TRANSLATIONSTRING $f | \ + uniq >$targetdir/tmp-translate + + echo -e -n "\nBuilding:" + echo -n " strings" + for i in $STRINGORDER; + do + echo + egrep '^\$str'$i'[[:alpha:]]*' $targetdir/tmp-tosort | sort + done | \ + uniq >>$targetdir/sort + + echo -n " pending_translations" + egrep -v $STRINGSTRING $targetdir/tmp-translate | uniq > $targetdir/translate + echo >> $targetdir/translate + for i in $STRINGORDER; + do + echo + egrep '^\$str'$i'[[:alpha:]]*' $targetdir/tmp-translate | sort + done | \ + uniq >>$targetdir/translate + + echo -e "\nAssembling final" + f=$f$2 + echo "$f + cat $targetdir/head $targetdir/sort $targetdir/translate >>$f + echo "?>" >>$f + + rm -rf $targetdir +} + +echo "-------------------------------------------------------------------" +for i in $1; +do + echo "Sorting $i" + sortlang $i + echo "-------------------------------------------------------------------" +done;