summaryrefslogtreecommitdiffstats
path: root/tools/scripts/update_translations.sh
blob: dd7adf6129f0d8f1d0c43824bb430f57726a6558 (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
#!/bin/sh

ldir=src/usr/local/share/locale
: ${MSGFMT=$(which msgfmt)}

if [ -z "${MSGFMT}" -o ! -e "${MSGFMT}" ]; then
	echo "ERROR: msgfmt not found"
	exit 1
fi

if [ ! -d $ldir ]; then
	echo "ERROR: Locale dir (${ldir}) not found"
	exit 1
fi

if ! ./tools/scripts/update_pot.sh; then
	echo "ERROR: Unable to update pot"
	exit 1
fi

if git status -s | grep -q "${ldir}/pot/pfSense.pot"; then
	git add ${ldir}/pot/pfSense.pot
	git commit -m "Regenerate pot"
	if ! zanata-cli -B push; then
		echo "ERROR: Unable to push pot to Zanata"
		exit 1
	fi
fi

#zanata-cli -B pull --min-doc-percent 75
if ! zanata-cli -B pull; then
	echo "ERROR: Unable to pull po files from Zanata"
	exit 1
fi

unset commit
for po in $(git status -s ${ldir}/*/*/pfSense.po | awk '{print $2}'); do
	if ! $MSGFMT -o ${po%%.po}.mo ${po}; then
		echo "ERROR: Error compiling ${po}"
		exit 1
	fi
	git add $(dirname ${po})
	commit=1
done

if [ -n "${commit}" ]; then
	git commit -m "Update translation files"
fi
OpenPOWER on IntegriCloud