1 |
#!/bin/bash |
2 |
|
3 |
# Functions |
4 |
. /etc/pootle/bin/functions |
5 |
|
6 |
# Clean up tmp dir |
7 |
rm -rf /etc/pootle/tmp |
8 |
mkdir -p /etc/pootle/tmp /var/www/html/{patches,errors,anaconda} |
9 |
|
10 |
#========================================================== |
11 |
|
12 |
export CVS_RSH=ssh |
13 |
|
14 |
# Update/expand smeserver cvs |
15 |
cd /etc/pootle/cvs/smeserver |
16 |
for pkg in */sme7 anaconda/sme8 booty/sme8 |
17 |
do |
18 |
make -C $pkg clean &> /dev/null |
19 |
done |
20 |
cvs update -dPA > /dev/null |
21 |
for pkg in */sme7 anaconda/sme8 booty/sme8 |
22 |
do |
23 |
make -C $pkg prep &> /dev/null |
24 |
done |
25 |
|
26 |
# Update/expand smecontribs cvs |
27 |
cd /etc/pootle/cvs/smecontribs |
28 |
for pkg in */contribs7 |
29 |
do |
30 |
make -C $pkg clean &> /dev/null |
31 |
done |
32 |
cvs update -dPA > /dev/null |
33 |
for pkg in */contribs7 |
34 |
do |
35 |
make -C $pkg prep &> /dev/null |
36 |
done |
37 |
|
38 |
cd /etc/pootle/tmp |
39 |
|
40 |
#========================================================== |
41 |
|
42 |
# Take server down to prevent translation issues |
43 |
killall PootleServer |
44 |
|
45 |
#========================================================== |
46 |
|
47 |
# Update anaconda templates |
48 |
anacondatmpl > anaconda.pot |
49 |
diffmv anaconda.pot /etc/pootle/po/sme7bc/templates/anaconda.pot |
50 |
|
51 |
# Update console templates |
52 |
potempl $(find /etc/pootle/cvs/smeserver/e-smith-quota/ -type f -name adminQuotaSummary.tmpl) > adminQuotaSummary.tmpl.pot |
53 |
diffmv adminQuotaSummary.tmpl.pot /etc/pootle/po/sme7bc/templates/adminQuotaSummary.tmpl.pot |
54 |
potempl $(find /etc/pootle/cvs/smeserver/e-smith-backup/ -type f -name do_backup -o -regex '.*/crontab/backup') > backup.pot |
55 |
diffmv backup.pot /etc/pootle/po/sme7bc/templates/backup.pot |
56 |
potempl $(find /etc/pootle/cvs/smeserver/e-smith-manager/ -type f -name 25Copyright) > foot.tmpl.pot |
57 |
diffmv foot.tmpl.pot /etc/pootle/po/sme7bc/templates/foot.tmpl.pot |
58 |
potempl $(find /etc/pootle/cvs/smeserver/ -type f -regex '.*/e-?smith/console.*') > server-console.pot |
59 |
diffmv server-console.pot /etc/pootle/po/sme7bc/templates/server-console.pot |
60 |
potempl $(find /etc/pootle/cvs/smeserver/e-smith-quota/ -type f -name userOverQuota.tmpl) > userOverQuota.tmpl.pot |
61 |
diffmv userOverQuota.tmpl.pot /etc/pootle/po/sme7bc/templates/userOverQuota.tmpl.pot |
62 |
|
63 |
# Update panel templates |
64 |
for pkg in $(find /etc/pootle/cvs/smeserver/*/*7/*/root/etc/e-smith/locale/en-us/ -type f -print) |
65 |
do |
66 |
xmltempl $pkg "SME Panels" |
67 |
diffcp /etc/pootle/templates/$(basename $pkg).pot /etc/pootle/po/sme7bp/templates/$(basename $pkg).pot |
68 |
done |
69 |
|
70 |
# Update sme7admin template |
71 |
potempl /etc/pootle/cvs/smecontribs/smeserver-sme7admin/*/*/root/{etc/e-smith/web/functions/sme7admin,usr/bin/sme7admind} > sme7admin.pot |
72 |
diffmv sme7admin.pot /etc/pootle/po/sme7cp/templates/sme7admin.pot |
73 |
|
74 |
# Update contrib panel templates |
75 |
for pkg in $(find /etc/pootle/cvs/smecontribs/*/*7/*/root/etc/e-smith/locale/en-us/ -type f -print) |
76 |
do |
77 |
xmltempl $pkg "Contrib Panels" |
78 |
diffcp /etc/pootle/templates/$(basename $pkg).pot /etc/pootle/po/sme7cp/templates/$(basename $pkg).pot |
79 |
done |
80 |
|
81 |
#========================================================== |
82 |
|
83 |
# Apply templates to languages |
84 |
for lang in $(ls -I templates /etc/pootle/po/sme* | grep '[[:alpha:]]$' | sort -u) |
85 |
do |
86 |
# Create compendium to assist translations |
87 |
pocompendium -c /etc/pootle/tmp/compendium-$lang.po -d /etc/pootle/po/*/$lang |
88 |
|
89 |
# Use compendium to migrate each project to new template |
90 |
for proj in $(ls -d /etc/pootle/po/sme*/$lang | sed 's@.*/\([^/]\+\)/[^/]\+$@\1@') |
91 |
do |
92 |
mkdir -p /etc/pootle/tmp/$proj/$lang |
93 |
pomigrate2 -F -C=/etc/pootle/tmp/compendium-$lang.po -q --no-wrap --locale=$lang /etc/pootle/po/$proj/$lang /etc/pootle/tmp/$proj/$lang /etc/pootle/po/$proj/templates > /dev/null |
94 |
|
95 |
# Ensure language is correct |
96 |
sed -i "/msgid \"en-us\"/{N;s@msgstr \"[^\"]*\"@msgstr \"$lang\"@}" /etc/pootle/tmp/$proj/$lang/* |
97 |
|
98 |
# Generate translation memory for panels |
99 |
updatetm --progress none -c 4 -i /etc/pootle/tmp/$proj/$lang -t /etc/pootle/tmp/compendium-$lang.po -o /etc/pootle/tmp/$proj/$lang |
100 |
done |
101 |
done |
102 |
|
103 |
# Set package name/version in new po files |
104 |
sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: SME Console\\n@' /etc/pootle/tmp/sme7bc/*/*.po |
105 |
sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: SME Anadonda\\n@' /etc/pootle/tmp/sme7bc/*/anaconda.po |
106 |
sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: SME Panels\\n@' /etc/pootle/tmp/sme7bp/*/*.po |
107 |
sed -i 's@Project-Id-Version.*\\n@Project-Id-Version: Contrib Panels\\n@' /etc/pootle/tmp/sme7cp/*/*.po |
108 |
|
109 |
# Move files that have changed |
110 |
for chk in $(find /etc/pootle/tmp/sme* -type f) |
111 |
do |
112 |
diffmv $chk $(echo $chk | sed 's@/tmp/@/po/@') |
113 |
done |
114 |
|
115 |
# Create error compendium to assist translators |
116 |
for lang in $(ls -I templates /etc/pootle/po/sme* | grep '[[:alpha:]]$' | sort -u) |
117 |
do |
118 |
pocompendium -e errors-$lang.po -d /etc/pootle/po/sme*/$lang |
119 |
sed -i '0,/^$/d;/^#~/d' errors-$lang.po |
120 |
sed -i ':a;/^\n*$/{$d;N;ba;}' errors-$lang.po |
121 |
chmod 644 errors-$lang.po |
122 |
diffmv errors-$lang.po /var/www/html/errors/errors-$lang.po |
123 |
done |
124 |
|
125 |
#========================================================== |
126 |
|
127 |
# Recalculate stats and restart server |
128 |
cd /etc/pootle |
129 |
PootleServer --refreshstats &> /dev/null |
130 |
nohup PootleServer --prefsfile /etc/pootle/pootle.prefs >> /var/log/pootle.log 2>&1 & |
131 |
|
132 |
#========================================================== |
133 |
|
134 |
cd /etc/pootle/tmp |
135 |
|
136 |
# Build diffs for languages |
137 |
for lang in $(ls /etc/pootle/po/sme7bp -I templates) |
138 |
do |
139 |
# Build anaconda files |
140 |
mkdir -p /var/www/html/anaconda/sme7/$lang/LC_MESSAGES |
141 |
anacondagen sme7 $lang > /var/www/html/anaconda/sme7/$lang/LC_MESSAGES/anaconda.mo |
142 |
[ -s /var/www/html/anaconda/sme7/$lang/LC_MESSAGES/anaconda.mo ] || rm -rf /var/www/html/anaconda/sme7/$lang |
143 |
|
144 |
mkdir -p /var/www/html/anaconda/sme8/$lang/LC_MESSAGES |
145 |
anacondagen sme8 $lang > /var/www/html/anaconda/sme8/$lang/LC_MESSAGES/anaconda.mo |
146 |
[ -s /var/www/html/anaconda/sme8/$lang/LC_MESSAGES/anaconda.mo ] || rm -rf /var/www/html/anaconda/sme8/$lang |
147 |
|
148 |
# Build console files |
149 |
pkgname=$(ls -d /etc/pootle/cvs/smeserver/smeserver-locale/*7/*/root | cut -d/ -f8) |
150 |
mkdir -p ${pkgname}.update/po/$lang |
151 |
for pkg in $(ls /etc/pootle/po/sme7bc/templates/ -I anaconda.pot | sed -n 's@\.pot@\.po@p') |
152 |
do |
153 |
msgcat -F --no-wrap /etc/pootle/po/sme7bc/$lang/$pkg \ |
154 |
| grep -v 'Project-Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|X-Generator' \ |
155 |
| sed '0,/msgid ""/{/^#/d};/^#,/d' \ |
156 |
> ${pkgname}.update/po/$lang/$pkg |
157 |
done |
158 |
|
159 |
# Build sme7admin file |
160 |
pkgname=$(ls -d /etc/pootle/cvs/smecontribs/smeserver-sme7admin/*7/*/root | cut -d/ -f8) |
161 |
mkdir -p ${pkgname}.update/po/$lang |
162 |
msgcat -F --no-wrap /etc/pootle/po/sme7cp/$lang/sme7admin.po \ |
163 |
| grep -v 'Project-Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|X-Generator' \ |
164 |
| sed '0,/msgid ""/{/^#/d};/^#,/d' \ |
165 |
> ${pkgname}.update/po/$lang/sme7admin.po |
166 |
done |
167 |
|
168 |
# Build translated xml files |
169 |
for pkg in $(ls /etc/pootle/po/sme7*p/templates/ -I sme7admin.pot | sed -n 's@\.pot@@p') |
170 |
do |
171 |
pkgname=$(find /etc/pootle/cvs/smecontribs/*/*7/*/root/etc/e-smith/locale/en-us -name $pkg | cut -d/ -f8) |
172 |
if [ -z "$pkgname" ] |
173 |
then |
174 |
if [ -z "$(find /etc/pootle/cvs/smeserver/*/*7/*/root/etc/e-smith/locale/en-us -name $pkg)" ] |
175 |
then |
176 |
echo -e "\n *** Can't find package for $pkg ***\n" |
177 |
continue |
178 |
fi |
179 |
pkgname=$(ls -d /etc/pootle/cvs/smeserver/smeserver-locale/*7/*/root | cut -d/ -f8) |
180 |
else |
181 |
mkdir -p ${pkgname}.update/$(localedir en-us $pkg) |
182 |
cat /etc/pootle/templates/$pkg.orig \ |
183 |
| perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \ |
184 |
> ${pkgname}.update/$(localedir en-us $pkg)/$pkg |
185 |
fi |
186 |
for lang in $(ls /etc/pootle/po/sme7bp -I templates) |
187 |
do |
188 |
mkdir -p ${pkgname}.update/$(localedir $lang $pkg) |
189 |
xmlgen /etc/pootle/po/sme7*p/$lang/${pkg}.po \ |
190 |
> ${pkgname}.update/$(localedir $lang $pkg)/$pkg |
191 |
done |
192 |
done |
193 |
|
194 |
# Build xml diffs |
195 |
for pkg in $(ls -d *.update | sed 's@.update$@@') |
196 |
do |
197 |
rm -f /var/www/html/patches/$(echo $pkg | sed 's/-[^-]\+$//')-*-locale-*.patch |
198 |
[ -d $pkg.update/root/etc/e-smith/locale ] || continue |
199 |
orig=/etc/pootle/cvs/sme*/*/*7/$pkg/root/etc/e-smith/locale |
200 |
diff -ruN $orig $pkg.update/root/etc/e-smith/locale \ |
201 |
| sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/root/.*\)@\1 \2@;/^diff -ruN/d' \ |
202 |
> /var/www/html/patches/$pkg-locale-$(date +%F).patch |
203 |
done |
204 |
|
205 |
# Build console diffs |
206 |
pkg=$(ls -d smeserver-locale-* | sed 's@.update$@@') |
207 |
orig=/etc/pootle/cvs/smeserver/smeserver-locale/*7/$pkg/po |
208 |
diff -ruN $orig $pkg.update/po \ |
209 |
| sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/po/.*\)@\1 \2@;/^diff -ruN/d' \ |
210 |
>> /var/www/html/patches/$pkg-locale-$(date +%F).patch |
211 |
|
212 |
# Build sme7admin diff |
213 |
pkg=$(ls -d smeserver-sme7admin-* | sed 's@.update$@@') |
214 |
orig=/etc/pootle/cvs/smecontribs/smeserver-sme7admin/*7/$pkg/po |
215 |
diff -ruN $orig $pkg.update/po \ |
216 |
| sed 's@^\(---\|+++\) [^ ]\+/\([^/]\+/po/.*\)@\1 \2@;/^diff -ruN/d' \ |
217 |
>> /var/www/html/patches/$pkg-locale-$(date +%F).patch |
218 |
|