Rev Author Line No. Line
250 kaklik 1 #!/bin/sh
2 # $Id: check_lang.sh,v 2.2 2004/06/29 08:20:47 nijel Exp $
3 ##
4 # Shell script to check that all language files are syncronized
5 # Catches duplicate/missing strings
6 #
7 # Robin Johnson <robbat2@users.sourceforge.net>
8 # August 9, 2002
9 ##
10  
11 MASTER="english-iso-8859-1.inc.php"
12 TMPDIR="tmp-check"
13 FILEPAT="*.inc.php"
14 STRINGMATCH='^[[:space:]]*\$[[:alnum:]_]+[[:blank:]]+='
15 IGNOREMATCH='strEncto|strKanjiEncodConvert|strXkana|allow_recoding'
16  
17 if [ "`which diffstat`" = "" ] ; then
18 echo 'You need diffstat to use this!'
19 exit 1
20 fi
21  
22 rm -rf $TMPDIR
23 mkdir -p $TMPDIR
24  
25 # Build the list of variables in each file
26 echo "Building data"
27 for f in $FILEPAT;
28 do
29 awk "/$STRINGMATCH/ && ! /$IGNOREMATCH/ { print \$1 }" $f | sort > $TMPDIR/$f
30 done
31  
32  
33 # Build the diff files used for checking
34 # And if there are no differences, delete the empty files
35 echo "Comparing data"
36 for f in $FILEPAT;
37 do
38 if [ ! $MASTER = $f ]; then
39 if diff -u $TMPDIR/$MASTER $TMPDIR/$f >$TMPDIR/$f.diff ; then
40 rm -f $TMPDIR/$f.diff $TMPDIR/$f
41 fi
42 fi
43 done
44  
45 # Cleanup
46 rm -f $TMPDIR/$MASTER
47  
48 # Build the nice difference table
49 echo "Differences"
50 diffstat -f 0 $TMPDIR/*.diff >$TMPDIR/diffstat 2>/dev/null
51 echo "Dupe Miss Filename"
52 head -n -1 $TMPDIR/diffstat | \
53 while read filename sep change add plus sub minus edits exclaim;
54 do
55 echo "$add $sub $filename";
56 done
57  
58 echo
59 echo "Dupe = Duplicate Variables"
60 echo "Miss = Missing Variables"
61 echo "For exact problem listings, look in the $TMPDIR/ directory"
62 echo "Please remember to remove '$TMPDIR/' once you are done"