File: update_po.sh

package info (click to toggle)
zabbix 1%3A5.0.8%2Bdfsg-1~bpo10%2B1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 135,200 kB
  • sloc: ansic: 250,674; sql: 209,763; php: 195,264; xml: 167,194; javascript: 46,671; sh: 5,339; makefile: 1,723; java: 1,337; cpp: 620; perl: 41
file content (44 lines) | stat: -rwxr-xr-x 1,521 bytes parent folder | download | duplicates (6)
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
#!/bin/bash

echo "Generating translation template..."

# xgettext will be used on all php files

cd $(dirname $0)/..
directory=$PWD
find ./ -type f -name '*.php' | sort -d -f > locale/POTFILES.in

# keyword "_n" is Zabbix frontend plural function
# keyword "_s" is Zabbix frontend placeholder function
# keyword "_x" is Zabbix frontend context function
# keyword "_xs" is Zabbix frontend context function
xgettext --files-from=locale/POTFILES.in --from-code=UTF-8 \
--omit-header \
--output=locale/frontend.pot \
--copyright-holder="Zabbix SIA" --no-wrap --sort-output \
--add-comments="GETTEXT:" --keyword=_n:1,2 --keyword=_s \
--keyword=_x:1,2c --keyword=_xs:1,2c --keyword=_xn:1,2,4c || exit 1

cd $directory/locale
#--sort-by-file

sed -i 's/^#, php-format/#, c-format/' frontend.pot
echo "Merging new strings in po files..."

for translation in */LC_MESSAGES/frontend.po; do
	echo -n "$translation" | cut -d/ -f1
	# fuzzy matching provides all kinds of interesting results, for example,
	# "NTLM authentication" is translated as "LDAP-Authentifizierung" - thus
	# it is disabled
	msgmerge --no-fuzzy-matching --no-wrap --update \
--backup=off "$translation" frontend.pot
	# dropping obsolete strings
	msgattrib --no-obsolete --no-wrap --sort-output $translation -o $translation
done

for translation in */LC_MESSAGES/frontend.po; do
	echo -ne "$translation\t"
	# setting output file to /dev/null so that unneeded messages.mo file
	# is not created
	msgfmt --use-fuzzy -c --statistics -o /dev/null $translation
done