This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhtml-build-upload.sh
executable file
·145 lines (128 loc) · 3.76 KB
/
html-build-upload.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/sh
# vim: set noexpandtab tw=0:
# Rebuild the documentation and upload this to the web server.
set -e # we want to fail on any error instead of risking uploading broken stuff
#set -x
SHADOWSRC_TRUNK="../../trunk"
rm -rf htdocs.gen/
echo "Generate the web pages translations with po4a"
po4a -v --previous htdocs.cfg
find htdocs.gen -name "*.pl" |
while read f
do
mv $f ${f%pl}po
done
for lang in $(grep po4a_langs htdocs.cfg | sed -e 's/\[po4a_langs\] //')
do
for f in htdocs.gen/*.${lang/pl/po}
do
sed -i -e "s/\.en\"; ?>/\.${lang/pl/po}\"; ?>/" $f
done
done
gen_translations() {
dir="$1"
total=$(LC_ALL=C msgfmt -o /dev/null --statistics "$dir"/*.pot 2>&1 | \
sed -ne "s/^.* \([0-9]*\) untranslated.*$/\1/p;d")
echo "<table>"
for pofile in "$dir"/*.po
do
lang=${pofile%.po}
lang=$(basename $lang)
stats=$(LC_ALL=C msgfmt -o /dev/null --statistics $pofile 2>&1)
echo -n "<tr><td>$lang</td><td>"
for type in translated fuzzy untranslated
do
strings=$(echo " $stats" | \
sed -ne "s/^.* \([0-9]*\) $type.*$/\1/p;d")
if [ -n "$strings" ]
then
pcent=$((strings*100/total))
width=$((strings*200/total))
echo -n "<img height=\"10\" src=\"$type.png\" "
echo -n "style=\"height: 1em;\" "
echo -n "width=\"$width\" "
echo -n "alt=\"$pcent% $type ($strings/$total), \" "
echo -n "title=\"$type: $pcent% ($strings/$total)\"/>"
fi
done
echo "</td></tr>"
done
echo "<? include \"table_translations_legend.php\";?>"
echo "</table>"
echo "<p>Last update: `LC_ALL=C date`.</p>"
}
echo Generate the translation statistics for bin
gen_translations $SHADOWSRC_TRUNK/po > htdocs.gen/table_translations_bin.php
echo Generate the translation statistics for doc
gen_translations $SHADOWSRC_TRUNK/man/po > htdocs.gen/table_translations_doc.php
echo Generate the translation statistics for htdocs
gen_translations po > htdocs.gen/table_translations_www.php
echo Extract the version
grep AM_INIT_AUTOMAKE $SHADOWSRC_TRUNK/configure.in | \
sed -e 's/^.*,\s*\([^"]*\)).*/\1/' > htdocs.gen/version.php
get_language() {
# FIXME: use gettext
case $1 in
ca)
echo -n "català"
;;
en)
echo -n "English"
;;
es)
echo -n "español"
;;
fr)
echo -n "français"
;;
it)
echo -n "Italiano"
;;
po)
echo -n "polski"
;;
de)
echo -n "Deutsch"
;;
*)
echo "Language '$1' not supported" >&2
exit 1
;;
esac
}
gen_language_footer() {
page="$1"
# echo "Generating language footer for $page"
page=${page%.en}
page=${page#htdocs/}
page=${page#htdocs.gen/}
out=htdocs.gen/$(dirname $page)/footer_$(basename $page)
echo "<div id=\"languages\">" > $out
for langcode in $(ls htdocs/$page.* htdocs.gen/$page.* 2>/dev/null)
do
langcode=${langcode#htdocs/$page.}
langcode=${langcode#htdocs.gen/$page.}
language=$(get_language $langcode)
echo "<a href=\"$(basename $page | sed -e 's/:/%3A/g').$langcode\">$language</a>" >> $out
done
echo "</div>" >> $out
# echo "done"
}
echo "Generating language footers"
for page in htdocs/*.en
do
gen_language_footer "$page"
done
find htdocs.gen -name "*.en" |
while read page
do
gen_language_footer "$page"
done
echo Uploading...
scp -pr htdocs/*.* pkg-shadow.alioth.debian.org:/var/lib/gforge/chroot/home/groups/pkg-shadow/htdocs
scp -pr htdocs/.htaccess pkg-shadow.alioth.debian.org:/var/lib/gforge/chroot/home/groups/pkg-shadow/htdocs
scp -pr htdocs.gen/*.* pkg-shadow.alioth.debian.org:/var/lib/gforge/chroot/home/groups/pkg-shadow/htdocs
#scp -pr coverage/* pkg-shadow.alioth.debian.org:/var/lib/gforge/chroot/home/groups/pkg-shadow/htdocs/coverage
ssh pkg-shadow.alioth.debian.org chgrp -R pkg-shadow /var/lib/gforge/chroot/home/groups/pkg-shadow/htdocs
ssh pkg-shadow.alioth.debian.org chmod -R g+rw /var/lib/gforge/chroot/home/groups/pkg-shadow/htdocs
echo done