summaryrefslogtreecommitdiffstats
path: root/tools/scripts/update_pot.sh
blob: cffd6e141518e143794d0dabe256a61e5562d874 (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
#!/bin/sh
#
# update_pot.sh
#
# part of pfSense (https://www.pfsense.org)
# Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Verify if user defined a custom path for xgettext
if [ -n "$XGETTEXT" ]; then
	if [ ! -x "$XGETTEXT" ]; then
		echo "XGETTEXT env var points to invalid executable"
		exit 1
	fi
elif ! which -s xgettext; then
	echo "xgettext not found, try to set env var XGETTEXT with full path"
	exit 1
else
	XGETTEXT=$(which xgettext)
fi

ROOT=$(realpath "$(dirname $0)/../..")

FILES=$(mktemp -t src-files-)

if [ -z "$FILES" -o ! -f "$FILES" ]; then
	echo "Error creating temporary file"
	exit 1
fi

trap "rm -f $FILES" 1 2 15 EXIT

( \
       cd $ROOT && \
       find src -type f -name '*.inc' -or -name '*.class' -or -name '*.php' \
) > $FILES

POT=$ROOT/src/usr/local/share/locale/en/LC_MESSAGES/pfSense.pot

( \
	cd $ROOT && \
	$XGETTEXT \
		-f $FILES \
		-o $POT \
		-L php \
		-ksetHelp \
		-kForm_Section \
		-kForm_Group \
		-kForm_Input:2 \
		-kForm_Checkbox:2 \
		-kForm_StaticText \
		-kModal \
		-kForm_Button:2 \
		-kForm_Textarea:2 \
		-kForm_MultiCheckboxGroup \
		-kForm_MultiCheckbox:2 \
		-kForm_IpAddress:2 \
		-kForm_Select:2 \
)

( \
	cd $ROOT && \
	$XGETTEXT \
		-f $FILES \
		-o $POT \
		-L php \
		-j \
		-kForm_Checkbox:3 \
		-kForm_StaticText:2 \
		-kForm_MultiCheckbox:3 \
)
OpenPOWER on IntegriCloud