Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sort_lang.sh « lang - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 42032da9b90d27cb2ec2ac543a36a362705f3b1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
# $Id$
##
# Shell script to make each language file neat and tidy
#
# Robin Johnson <robbat2@users.sourceforge.net>
# 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()
{
    f=$1
    targetdir=tmp-$f
    mkdir -p $targetdir

    TRANSLATIONSTRING='//.*translate.*$'
    STRINGSTRING='^\$str[[:alnum:]_]+'
    WHITESPACE='^[[:blank:]]*$'
    CVSID='/\* \$Id$ \*/'

    echo -n "Extracting:"
    echo -n " head"
    egrep -i -v $TRANSLATIONSTRING $f | \
    egrep -v "$STRINGSTRING|$CVSID|\?>|<\?php" >> $targetdir/head

    echo -n " cvs"
    egrep "$CVSID" $f >>$targetdir/cvs

    echo -n " strings"
    egrep -i -v "$WHITESPACE|$TRANSLATIONSTRING" $f | \
    egrep $STRINGSTRING > $targetdir/tmp-tosort

    echo -n " pending_translations"
    egrep -i "$STRINGSTRING.*$TRANSLATIONSTRING" $f > $targetdir/tmp-translate
    echo

    echo -n "Building:"
    echo -n " strings"
    specialsort $targetdir/tmp-tosort $targetdir/sort

    echo -n " pending_translations"
    if [ -s $targetdir/tmp-translate ] ; then
        echo '// To translate:' > $targetdir/translate
        specialsort $targetdir/tmp-translate $targetdir/translate
    else
        echo -n > $targetdir/translate
    fi
    echo

    echo "Assembling final"
    echo "<?php" > $f
    cat $targetdir/cvs $targetdir/head $targetdir/sort $targetdir/translate \
    | uniq >> $f
    echo "?>" >> $f

    rm -rf $targetdir
}

echo "-------------------------------------------------------------------"
for i in "$@"; 
do
    if [ ! -f $i ] ; then
        echo "$i is not a file, skipping"
    else
        echo "Sorting $i"
        sortlang $i
    fi
    echo "-------------------------------------------------------------------"
done;