home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / check_lang.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2003-11-26  |  1.4 KB  |  58 lines

  1. #!/bin/sh
  2. # $Id: check_lang.sh,v 2.1 2003/11/26 20:42:58 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. rm -rf $TMPDIR
  18. mkdir -p $TMPDIR
  19.  
  20. # Build the list of variables in each file
  21. echo "Building data"
  22. for f in $FILEPAT;
  23. do
  24.     awk "/$STRINGMATCH/ && ! /$IGNOREMATCH/ { print \$1 }" $f | sort > $TMPDIR/$f
  25. done
  26.  
  27.  
  28. # Build the diff files used for checking
  29. # And if there are no differences, delete the empty files
  30. echo "Comparing data"
  31. for f in $FILEPAT;
  32. do
  33.     if [ ! $MASTER = $f ]; then
  34.         if diff -u $TMPDIR/$MASTER $TMPDIR/$f >$TMPDIR/$f.diff ; then
  35.             rm -f $TMPDIR/$f.diff $TMPDIR/$f
  36.         fi
  37.     fi
  38. done
  39.  
  40. # Cleanup
  41. rm -f $TMPDIR/$MASTER
  42.  
  43. # Build the nice difference table
  44. echo "Differences"
  45. diffstat -f 0 $TMPDIR/*.diff >$TMPDIR/diffstat 2>/dev/null
  46. echo "Dupe    Miss    Filename"
  47. head -n -1 $TMPDIR/diffstat | \
  48. while read filename sep change add plus sub minus edits exclaim; 
  49. do 
  50.     echo "$add    $sub    $filename"; 
  51. done
  52.  
  53. echo
  54. echo "Dupe = Duplicate Variables"
  55. echo "Miss = Missing Variables"
  56. echo "For exact problem listings, look in the $TMPDIR/ directory"
  57. echo "Please remember to remove '$TMPDIR/' once you are done"
  58.