forked from roloa/Cataclysm-DDA_variant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge_po.sh
executable file
·64 lines (61 loc) · 1.81 KB
/
merge_po.sh
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
#!/usr/bin/env bash
if [ ! -d lang/po ]
then
if [ -d ../lang/po ]
then
cd ..
else
echo "Error: Could not find lang/po subdirectory."
exit 1
fi
fi
# merge incoming translations for each language specified on the commandline
if [ $# -gt 0 ]
then
for n in $@
do
if [ -f lang/incoming/${n}.po ]
then
if [ -f lang/po/${n}.po ]
then
echo "merging lang/incoming/${n}.po"
msgcat -F --use-first lang/incoming/${n}.po lang/po/${n}.po -o lang/po/${n}.po && rm lang/incoming/${n}.po
else
echo "importing lang/incoming/${n}.po"
mv lang/incoming/${n}.po lang/po/${n}.po
fi
fi
done
# if nothing specified, merge all incoming translations
elif [ -d lang/incoming ]
then
shopt -s nullglob # work as expected if nothing matches *.po
for f in lang/incoming/*.po
do
n=`basename ${f} .po`
if [ -f lang/po/${n}.po ]
then
echo "merging ${f}"
msgcat -F --use-first ${f} lang/po/${n}.po -o lang/po/${n}.po && rm ${f}
else
echo "importing ${f}"
mv ${f} lang/po/${n}.po
fi
done
fi
# merge lang/po/cataclysm-dda.pot with .po file for each specified language
if [ $# -gt 0 ]
then
for n in $@
do
echo "updating lang/po/${n}.po"
msgmerge --sort-by-file --no-fuzzy-matching lang/po/${n}.po lang/po/cataclysm-dda.pot | msgattrib --sort-by-file --no-obsolete -o lang/po/${n}.po
done
# otherwise merge lang/po/cataclysm-dda.pot with all .po files in lang/po
else
for f in lang/po/*.po
do
echo "updating $f"
msgmerge --sort-by-file --no-fuzzy-matching $f lang/po/cataclysm-dda.pot | msgattrib --sort-by-file --no-obsolete -o $f
done
fi