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