-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·144 lines (111 loc) · 3.66 KB
/
build.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#
# Auto generate properties files out of po files
#
# Author: Dominik Brämer <[email protected]>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.
#
# License GPLv3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
TEMPLATE=./po/yawls_template.pot
MANTEMPLATE=./po/yawls_man_template.pot
#Check Translation for empty or fuzzy strings -------------------------------------------
function checkPoFile() {
COUNT=0
while read LINE; do
if [[ "$LINE" == 'msgstr ""' ]]; then
read LINE
[[ -z "$LINE" ]] && ((COUNT++))
fi
if [[ "$LINE" == 'fuzzy' ]]; then
((COUNT++))
fi
done <$1
PERC=$((100*$COUNT/$MSGCOUNT))
if [[ "$PERC" -lt "20" ]]; then
return 0
else
return 1
fi
}
#Prepare translation --------------------------------------------------------------------
#Concat Last-Translators ----------------------------------------------------------------
AUTHORS=""
function translators() {
LT=$(grep 'Last-Translator:' "$1" | grep -o ' .* ')
LT=${LT# }
LT=${LT% }
if [[ "$(echo "$AUTHORS" | grep "$LT")" == "" ]] && [[ "$LT" != "FULL NAME" ]]; then
if [[ "$AUTHORS" == "" ]]; then
AUTHORS="$LT"
else
AUTHORS="$AUTHORS\n$LT"
fi
fi
}
#Delete old translations
rm -f ./src/com/blogspot/thedsweb/local/*.properties
#Upate template
xgettext './src/com/blogspot/thedsweb/main/Yawls.java' './src/com/blogspot/thedsweb/gui/Show.java' --from-code=UTF-8 -k_ -o $TEMPLATE
sed 's/CHARSET/UTF-8/g' -i $TEMPLATE
msgcat -p $TEMPLATE -o ./src/com/blogspot/thedsweb/local/yawls_template.properties
for i in ./po/yawls_template-*.po; do
msgmerge -q -U $i $TEMPLATE
MSGCOUNT=$(grep -c 'msgid' $i)
if checkPoFile $i; then
translators $i
FILE=./src/com/blogspot/thedsweb/local/$(basename ${i%.*} | sed 's/-/_/g').properties
msgcat -p $i -o $FILE
sed -i 's/\\\\/\\/g' $FILE
fi
done
#Prepare man page translation -----------------------------------------------------------
#Delete old man page lists
rm -f ./debian/yawls.manpages
rm -f ./man/yawls.*.1
#Create new man page lists
echo man/yawls.1 >> ./debian/yawls.manpages
#Upate template
po4a-gettextize -f man -M UTF-8 -m ./man/yawls.1 -p $MANTEMPLATE
COMMENTS=""
for i in ./po/yawls_man_template-*.po; do
LOCAL=$(basename ${i%.*})
LOCAL=${LOCAL#*-}
if [[ $LOCAL == "*" ]]; then
break
fi
po4a-updatepo --msgmerge-opt -q -f man -M UTF-8 -m ./man/yawls.1 -p $i
MSGCOUNT=$(grep -c 'msgid' $i)
if checkPoFile $i; then
translators $i
DIS=$(grep -A 1 'msgid "Yawls automatic display brightness"' "$i" | grep 'msgstr')
DIS=${DIS#*\"}
DIS=${DIS%\"}
if [[ "$DIS" != "" ]]; then
if [[ "$COMMENTS" == "" ]]; then
COMMENTS="Comment[$LOCAL]=$DIS"
else
COMMENTS="$COMMENTS\nComment[$LOCAL]=$DIS"
fi
fi
if [[ "$(echo "$LOCAL" | grep "en_*")" == "" ]]; then
po4a-translate -f man -M UTF-8 -m ./man/yawls.1 -p $i -l ./man/yawls.$LOCAL.1
echo man/yawls.$LOCAL.1 >> ./debian/yawls.manpages
fi
fi
done
echo $AUTHORS > ./translator.txt
#Add translated discription to menu file ------------------------------------------------
sed -e '/^Comment\[/ d' \
-e '/Comment=Yawls automatic display brightness/a '"$COMMENTS" \
-i './Yawls.desktop'