-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate
executable file
·71 lines (57 loc) · 1.7 KB
/
update
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
#! /bin/bash
# Kunststube\POTools .pot to .po file updater.
# Takes two parameters: path to a locale directory
# and name of the master locale. Merges all .pot files
# of the master locale into equivalent .po files
# of all other locales.
if [ $# -ne 2 ]
then
echo "Missing parameters. Usage:"
echo
echo " $0 <path-to-locale-dir> <master-locale>"
echo
exit 1
fi
LOCALEDIR="$1"
MASTERLOCALE="$2"
if [ ! -d "$LOCALEDIR" ]
then
echo "Error: Directory '$LOCALEDIR' not found"
echo
exit 1
fi
if [ ! -d "$LOCALEDIR/$MASTERLOCALE" ]
then
echo "Error: Directory '$LOCALEDIR/$MASTERLOCALE' not found"
echo
exit 1
fi
MASTERLOCALEDIR="$LOCALEDIR/$MASTERLOCALE"
POTFILES=( $(find "$MASTERLOCALEDIR" -type f -name "*.pot") )
echo "Found ${#POTFILES[@]} master locale files in '$MASTERLOCALEDIR':"
echo ${POTFILES[@]//$MASTERLOCALEDIR\/}
echo
LOCALES=( $(find -H "$LOCALEDIR" -type d -depth 1 \! -name "$MASTERLOCALE" \! -name ".*") )
echo "Found ${#LOCALES[@]} locale(s) in '$LOCALEDIR':"
echo ${LOCALES[@]//$LOCALEDIR\/}
echo
for locale in "${LOCALES[@]}"
do
echo "Processing ${locale#$LOCALEDIR\/}..."
echo
for potFile in "${POTFILES[@]}"
do
poFile="$locale/${potFile#$MASTERLOCALEDIR\/}"
poFile="${poFile%t}"
if [ ! -f $poFile ]
then
echo "Equivalent '$poFile' for '$potFile' does not exist, please initialize it first."
echo "Skipping..."
echo
continue
fi
echo "Merging $potFile -> $poFile..."
msgmerge -Uv --previous --no-wrap "$poFile" "$potFile"
echo
done
done