update
[phpmyadmin/crack.git] / lang / check_lang.sh
blobe1a6eb114526476e633f8887d4a4d29116d4c8c1
1 #!/bin/bash
2 # $Id$
3 ##
4 # Shell script to check that all language files are syncronized
5 # Catches duplicate/missing strings
7 # Robin Johnson <robbat2@users.sourceforge.net>
8 # August 9, 2002
9 ##
10 MASTER="english-iso-8859-1.inc.php3"
11 TMPDIR="tmp-check"
12 FILEPAT="*.inc.php3"
13 STRINGSTRING='^[[:space:]]*\$[[:alnum:]_]*[[:blank:]]* ='
15 rm -rf $TMPDIR
16 mkdir -p $TMPDIR
18 #Build the list of variables in each file
19 #Note the special case to strip out allow_recoding
20 echo -e "Building data"
21 for f in $FILEPAT;
24 egrep "$STRINGSTRING" $f | \
25 grep -v 'allow_recoding' | \
26 cut -d= -f1 | cut -d'$' -f2 | \
27 grep -Ev 'strEncto|strKanjiEncodConvert|strXkana' | \
28 sort > $TMPDIR/$f
29 done;
31 #Build the diff files used for checking
32 #And if there are no differences, delete the empty files
33 echo -e "Comparing data"
34 for f in $FILEPAT;
36 diff -u $TMPDIR/$MASTER $TMPDIR/$f >$TMPDIR/$f.diff
37 if [ ! $MASTER == $f ]; then
38 if [ `wc -l $TMPDIR/$f.diff | cut -c-8|xargs` == "0" ] ;
39 then
40 rm -f $TMPDIR/$f.diff $TMPDIR/$f
41 fi;
42 fi;
43 done;
45 #build the nice difference table
46 echo -e "Differences"
47 diffstat -f 0 $TMPDIR/*.diff >$TMPDIR/diffstat 2>/dev/null
48 head -n $((`wc -l <$TMPDIR/diffstat` - 1)) $TMPDIR/diffstat > $TMPDIR/diffstat.res
49 echo -e "Dupe\tMiss\tFilename"
50 cat $TMPDIR/diffstat.res | \
51 while read filename sep change add plus sub minus edits exclaim;
52 do
53 echo -e "$add\t$sub\t$filename";
54 done;
56 echo
57 echo "Dupe = Duplicate Variables"
58 echo "Miss = Missing Variables"
59 echo "For exact problem listings, look in the $TMPDIR/ directory"
60 echo "Please remember to remove '$TMPDIR/' once you are done"