cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# $Id$
|
# $Id$
|
||||||
##
|
##
|
||||||
# Shell script to check that all language files are syncronized
|
# Shell script to check that all language files are syncronized
|
||||||
@@ -7,51 +7,48 @@
|
|||||||
# Robin Johnson <robbat2@users.sourceforge.net>
|
# Robin Johnson <robbat2@users.sourceforge.net>
|
||||||
# August 9, 2002
|
# August 9, 2002
|
||||||
##
|
##
|
||||||
|
|
||||||
MASTER="english-iso-8859-1.inc.php"
|
MASTER="english-iso-8859-1.inc.php"
|
||||||
TMPDIR="tmp-check"
|
TMPDIR="tmp-check"
|
||||||
FILEPAT="*.inc.php"
|
FILEPAT="*.inc.php"
|
||||||
STRINGSTRING='^[[:space:]]*\$[[:alnum:]_]*[[:blank:]]* ='
|
STRINGMATCH='^[[:space:]]*\$[[:alnum:]_]+[[:blank:]]+='
|
||||||
|
IGNOREMATCH='strEncto|strKanjiEncodConvert|strXkana|allow_recoding'
|
||||||
|
|
||||||
rm -rf $TMPDIR
|
rm -rf $TMPDIR
|
||||||
mkdir -p $TMPDIR
|
mkdir -p $TMPDIR
|
||||||
|
|
||||||
#Build the list of variables in each file
|
# Build the list of variables in each file
|
||||||
#Note the special case to strip out allow_recoding
|
echo "Building data"
|
||||||
echo -e "Building data"
|
for f in $FILEPAT;
|
||||||
for f in $FILEPAT;
|
|
||||||
do
|
do
|
||||||
|
awk "/$STRINGMATCH/ && ! /$IGNOREMATCH/ { print \$1 }" $f | sort > $TMPDIR/$f
|
||||||
|
done
|
||||||
|
|
||||||
egrep "$STRINGSTRING" $f | \
|
|
||||||
grep -v 'allow_recoding' | \
|
|
||||||
cut -d= -f1 | cut -d'$' -f2 | \
|
|
||||||
grep -Ev 'strEncto|strKanjiEncodConvert|strXkana' | \
|
|
||||||
sort > $TMPDIR/$f
|
|
||||||
done;
|
|
||||||
|
|
||||||
#Build the diff files used for checking
|
# Build the diff files used for checking
|
||||||
#And if there are no differences, delete the empty files
|
# And if there are no differences, delete the empty files
|
||||||
echo -e "Comparing data"
|
echo "Comparing data"
|
||||||
for f in $FILEPAT;
|
for f in $FILEPAT;
|
||||||
do
|
do
|
||||||
diff -u $TMPDIR/$MASTER $TMPDIR/$f >$TMPDIR/$f.diff
|
if [ ! $MASTER = $f ]; then
|
||||||
if [ ! $MASTER == $f ]; then
|
if diff -u $TMPDIR/$MASTER $TMPDIR/$f >$TMPDIR/$f.diff ; then
|
||||||
if [ `wc -l $TMPDIR/$f.diff | cut -c-8|xargs` == "0" ] ;
|
|
||||||
then
|
|
||||||
rm -f $TMPDIR/$f.diff $TMPDIR/$f
|
rm -f $TMPDIR/$f.diff $TMPDIR/$f
|
||||||
fi;
|
fi
|
||||||
fi;
|
fi
|
||||||
done;
|
done
|
||||||
|
|
||||||
#build the nice difference table
|
# Cleanup
|
||||||
echo -e "Differences"
|
rm -f $TMPDIR/$MASTER
|
||||||
|
|
||||||
|
# Build the nice difference table
|
||||||
|
echo "Differences"
|
||||||
diffstat -f 0 $TMPDIR/*.diff >$TMPDIR/diffstat 2>/dev/null
|
diffstat -f 0 $TMPDIR/*.diff >$TMPDIR/diffstat 2>/dev/null
|
||||||
head -n $((`wc -l <$TMPDIR/diffstat` - 1)) $TMPDIR/diffstat > $TMPDIR/diffstat.res
|
echo "Dupe Miss Filename"
|
||||||
echo -e "Dupe\tMiss\tFilename"
|
head -n -1 $TMPDIR/diffstat | \
|
||||||
cat $TMPDIR/diffstat.res | \
|
|
||||||
while read filename sep change add plus sub minus edits exclaim;
|
while read filename sep change add plus sub minus edits exclaim;
|
||||||
do
|
do
|
||||||
echo -e "$add\t$sub\t$filename";
|
echo "$add $sub $filename";
|
||||||
done;
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Dupe = Duplicate Variables"
|
echo "Dupe = Duplicate Variables"
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# $Id$
|
# $Id$
|
||||||
##
|
##
|
||||||
# Shell script to make each language file neat and tidy
|
# Shell script to make each language file neat and tidy
|
||||||
@@ -7,6 +7,20 @@
|
|||||||
# August 9, 2002
|
# August 9, 2002
|
||||||
##
|
##
|
||||||
|
|
||||||
|
specialsort()
|
||||||
|
{
|
||||||
|
in=$1
|
||||||
|
out=$2
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
for i in $STRINGORDER;
|
||||||
|
do
|
||||||
|
egrep '^\$str'$i $in | sort >> $out
|
||||||
|
echo >> $out
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
sortlang()
|
sortlang()
|
||||||
{
|
{
|
||||||
f=$1
|
f=$1
|
||||||
@@ -14,70 +28,56 @@ sortlang()
|
|||||||
mkdir -p $targetdir
|
mkdir -p $targetdir
|
||||||
|
|
||||||
TRANSLATIONSTRING='//.*translate.*$'
|
TRANSLATIONSTRING='//.*translate.*$'
|
||||||
STRINGSTRING='^[[:space:]]*\$str[[:alnum:]_]*'
|
STRINGSTRING='^\$str[[:alnum:]_]+'
|
||||||
WHITESPACE='^[[:blank:]]*$'
|
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"
|
CVSID='/\* \$Id$ \*/'
|
||||||
CVSID='/* .Id: .* . */'
|
|
||||||
|
|
||||||
echo -en "Extracting:"
|
echo -n "Extracting:"
|
||||||
echo -en " head"
|
echo -n " head"
|
||||||
egrep -i -v $TRANSLATIONSTRING $f | \
|
egrep -i -v $TRANSLATIONSTRING $f | \
|
||||||
egrep -v "$STRINGSTRING|$CVSID" | \
|
egrep -v "$STRINGSTRING|$CVSID|\?>|<\?php" >> $targetdir/head
|
||||||
sed 's/?>//g;s/<?php//g'| \
|
|
||||||
uniq >>$targetdir/head
|
|
||||||
|
|
||||||
echo -en " cvs"
|
echo -n " cvs"
|
||||||
head -n10 $f | \
|
egrep "$CVSID" $f >>$targetdir/cvs
|
||||||
egrep "$CVSID" >>$targetdir/cvs
|
|
||||||
|
|
||||||
echo -en " strings"
|
echo -n " strings"
|
||||||
egrep -i -v $TRANSLATIONSTRING $f | \
|
egrep -i -v "$WHITESPACE|$TRANSLATIONSTRING" $f | \
|
||||||
egrep $STRINGSTRING | \
|
egrep $STRINGSTRING > $targetdir/tmp-tosort
|
||||||
egrep -v $WHITESPACE >$targetdir/tmp-tosort
|
|
||||||
|
|
||||||
echo -en " pending_translations"
|
echo -n " pending_translations"
|
||||||
egrep -i $TRANSLATIONSTRING $f | \
|
egrep -i "$STRINGSTRING.*$TRANSLATIONSTRING" $f > $targetdir/tmp-translate
|
||||||
uniq >$targetdir/tmp-translate
|
echo
|
||||||
|
|
||||||
echo -en "\nBuilding:"
|
echo -n "Building:"
|
||||||
echo -en " strings"
|
echo -n " strings"
|
||||||
for i in $STRINGORDER;
|
specialsort $targetdir/tmp-tosort $targetdir/sort
|
||||||
do
|
|
||||||
echo
|
|
||||||
egrep '^\$str'$i'[[:alpha:]]*' $targetdir/tmp-tosort | \
|
|
||||||
sort -k 1,1
|
|
||||||
done | \
|
|
||||||
uniq >>$targetdir/sort
|
|
||||||
|
|
||||||
echo -en " pending_translations"
|
echo -n " pending_translations"
|
||||||
egrep -v $STRINGSTRING $targetdir/tmp-translate | uniq > $targetdir/translate
|
if [ -s $targetdir/tmp-translate ] ; then
|
||||||
echo >> $targetdir/translate
|
echo '// To translate:' > $targetdir/translate
|
||||||
for i in $STRINGORDER;
|
specialsort $targetdir/tmp-translate $targetdir/translate
|
||||||
do
|
else
|
||||||
echo
|
echo -n > $targetdir/translate
|
||||||
egrep '^\$str'$i'[[:alpha:]]*' $targetdir/tmp-translate | \
|
fi
|
||||||
sort -k 1,1
|
echo
|
||||||
done | \
|
|
||||||
uniq >>$targetdir/translate
|
|
||||||
|
|
||||||
echo -en "\nAssembling final\n"
|
echo "Assembling final"
|
||||||
f=$f$2
|
echo "<?php" > $f
|
||||||
echo "<?php" >$f
|
cat $targetdir/cvs $targetdir/head $targetdir/sort $targetdir/translate \
|
||||||
cat $targetdir/cvs $targetdir/head $targetdir/sort $targetdir/translate | \
|
| uniq >> $f
|
||||||
uniq >>$f
|
echo "?>" >> $f
|
||||||
echo "?>" >>$f
|
|
||||||
|
|
||||||
rm -rf $targetdir
|
rm -rf $targetdir
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "-------------------------------------------------------------------"
|
echo "-------------------------------------------------------------------"
|
||||||
for i in $1;
|
for i in "$@";
|
||||||
do
|
do
|
||||||
if [ ! -f $i ] ; then
|
if [ ! -f $i ] ; then
|
||||||
echo "$i is not a file, skipping"
|
echo "$i is not a file, skipping"
|
||||||
else
|
else
|
||||||
echo "Sorting $i"
|
echo "Sorting $i"
|
||||||
sortlang $i $2
|
sortlang $i
|
||||||
fi
|
fi
|
||||||
echo "-------------------------------------------------------------------"
|
echo "-------------------------------------------------------------------"
|
||||||
done;
|
done;
|
||||||
|
Reference in New Issue
Block a user