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

prepare-translation.sh « extract_translations « contrib - github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 64bd03993108d4afebe7ddeb21ba503df16b362d (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

# Frontend for ejabberd's extract_translations.erl
# by Badlop
# last updated: 8 December 2005

while [ "$1" != "" ] 
do
    case "$1" in
        -help)
            echo "Options:"
            echo "  -lang LANGUAGE"
            echo "  -src FULL_PATH_EJABBERD"
            echo ""
            echo "Example:"
            echo "  ./prepare-translation.sh -lang es -src /home/admin/ejabberd"
            exit 0
            ;;
        -lang)
            # This is the language to be extracted
            LANGU=$2
            shift
            shift
            ;;
        -src)
            # This is the path to the ejabberd source dir
            EJA_DIR=$2
            shift
            shift
            ;;
        *)
            echo "unknown option: '$1 $2'"
            shift
            shift
            ;;
    esac
done

# Where is Erlang binary
ERL=`which erl`

EXTRACT_DIR=$EJA_DIR/contrib/extract_translations/
EXTRACT_ERL=extract_translations.erl
EXTRACT_BEAM=extract_translations.beam
SRC_DIR=$EJA_DIR/src
MSGS_DIR=$SRC_DIR/msgs
MSGS_FILE=$LANGU.msg
MSGS_FILE2=$LANGU.msg.translate
MSGS_PATH=$MSGS_DIR/$MSGS_FILE
MSGS_PATH2=$MSGS_DIR/$MSGS_FILE2

if !([[ -n $EJA_DIR ]])
then 
echo "ejabberd dir does not exist: $EJA_DIR"
fi

if !([[ -x $EXTRACT_BEAM ]])
then 
echo -n "Compiling extract_translations.erl: "
sh -c "cd $EXTRACT_DIR; $ERL -compile $EXTRACT_ERL"
fi

echo ""
echo -n "Extracting language strings for '$LANGU':"

echo -n " new..."
$ERL -pa $EXTRACT_DIR -noinput -noshell -s extract_translations -s init stop -extra $SRC_DIR $MSGS_PATH >$MSGS_PATH.new

echo -n " old..."
$ERL -pa $EXTRACT_DIR -noinput -noshell -s extract_translations -s init stop -extra -unused $SRC_DIR $MSGS_PATH >$MSGS_PATH.unused

cat $MSGS_PATH >$MSGS_PATH2

echo "" >>$MSGS_PATH2

cat $MSGS_PATH.new >>$MSGS_PATH2
rm $MSGS_PATH.new
echo "" >>$MSGS_PATH2

cat $MSGS_PATH.unused >>$MSGS_PATH2
rm $MSGS_PATH.unused

echo " ok"

echo ""
echo "Process completed."

echo ""
echo "  A new file has been created for you, with the current, the new and the deprecated strings:"
echo "  $MSGS_PATH2"
echo ""
echo "  At the end of that file you will find the strings you must update:"
echo "   - Untranslated strings are like this: {"March", ""}."
echo "     To translate the string, add the text inside the commas. Example:"
echo "     {"March", "Marzo"}."
echo "   - Old strings that are not used: "Woowoa""
echo "     Search the entire file for those strings and remove them"
echo ""
echo "  Once you have translated all the strings and removed all the old ones,"
echo "  rename the file to overwrite the previous one:"
echo "  $MSGS_PATH"