bug #3056023 [import] USE query not working
[phpmyadmin/crack.git] / lang / sort_lang.sh
blob6d505929d99a4fc66c020f8950f97417219bb37c
1 #!/bin/sh
2 # $Id$
3 ##
4 # Shell script to make each language file neat and tidy
6 # Robin Johnson <robbat2@users.sourceforge.net>
7 # August 9, 2002
8 ##
10 LC_COLLATE=C
12 specialsort()
14 in=$1
15 out=$2
17 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"
19 for i in $STRINGORDER;
21 egrep '^\$str'$i $in | sort >> $out
22 echo >> $out
23 done
26 sortlang()
28 f=$1
29 targetdir=tmp-$f
30 mkdir -p $targetdir
32 TRANSLATIONSTRING='//.*translate.*$'
33 STRINGSTRING='^\$str[[:alnum:]_]+'
34 WHITESPACE='^[[:blank:]]*$'
35 CVSID='/\* \$Id$ \*/'
37 echo -n "Extracting:"
38 echo -n " head"
39 egrep -i -v $TRANSLATIONSTRING $f | \
40 egrep -v "$STRINGSTRING|$CVSID|\?>|<\?php" >> $targetdir/head
42 echo -n " cvs"
43 egrep "$CVSID" $f >>$targetdir/cvs
45 echo -n " strings"
46 egrep -i -v "$WHITESPACE|$TRANSLATIONSTRING" $f | \
47 egrep $STRINGSTRING > $targetdir/tmp-tosort
49 echo -n " pending_translations"
50 egrep -i "$STRINGSTRING.*$TRANSLATIONSTRING" $f > $targetdir/tmp-translate
51 echo
53 echo -n "Building:"
54 echo -n " strings"
55 specialsort $targetdir/tmp-tosort $targetdir/sort
57 echo -n " pending_translations"
58 if [ -s $targetdir/tmp-translate ] ; then
59 echo '// To translate:' > $targetdir/translate
60 specialsort $targetdir/tmp-translate $targetdir/translate
61 else
62 echo -n > $targetdir/translate
64 echo
66 echo "Assembling final"
67 echo "<?php" > $f
68 cat $targetdir/cvs $targetdir/head $targetdir/sort $targetdir/translate \
69 | uniq >> $f
70 echo "?>" >> $f
72 rm -rf $targetdir
75 echo "-------------------------------------------------------------------"
76 for i in "$@";
78 if [ ! -f $i ] ; then
79 echo "$i is not a file, skipping"
80 else
81 echo "Sorting $i"
82 sortlang $i
84 echo "-------------------------------------------------------------------"
85 done;