Update statistics script.

This commit is contained in:
Andrius Štikonas 2018-12-28 12:14:33 +00:00
parent 17f5c593ee
commit ae27570b60
9 changed files with 79 additions and 1459 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

View File

@ -1,233 +0,0 @@
body {
margin: 0;
padding: 0;
background: #FFFBF0;
color: #111;
font: 0.88em sans-serif;
}
p {
margin: 0 0 1em 0;
}
table.main {
background: #8b898b;
}
table.title {
background: #ececec;
}
tr.row-0 {
background: #ececec;
}
tr.row-1{
background: #ccecec;
}
tr.header {
background: #dddddd;
}
td.title {
font-weight: bold;
}
td.percentage-0 {
background: #f5f5f5;
}
td.percentage-1 {
background: #e0f5f5;
}
td.translated {
color: #05a505;
text-align: center;
font-weight: bold;
}
td.fuzzy {
color: #0505a5;
text-align: center;
font-weight: bold;
}
td.untranslated {
color: #a50505;
text-align: center;
}
h4 {
margin: 1em 0 0 0;
}
a {
color: #A48736;
}
hr {
display: none;
}
/**
* Main
*/
#main {
padding: 0 8% 0 8%;
color: #333;
font-size: 0.8em;
text-align: left;
line-height: 1.6em;
/* ie5win damn hack */
width: 100%;
}
html>body #main {
width: 84%;
}
/* -------- homepage layout start -------- */
#main #left {
position: relative;
float: left;
width: 49%;
}
#main #right {
position: relative;
float: right;
width: 50%;
}
/* -------- homepage layout end -------- */
#main div.container {
margin: 15px 3px 15px 3px;
padding: 15px;
background: #EEE;
border: 2px solid #AAA;
-moz-border-radius: 4px 4px 4px 4px;
}
#main div.new {
margin: 14px 0 0 0;
}
#main div.new div.new-title {
font-weight: bold;
}
#main div.new div.new-date {
font-size: 0.9em;
}
#main div.new p {
margin: 4px 0 4px 0;
}
#main div.sshots {
text-align: center;
}
#main #sshots a:hover {
border: none;
}
#main div.sshots a {
text-decoration: none;
font-size: 0.7em;
}
#main img {
border: none;
margin: 2px 2px 6px 2px;
padding: 3px;
background: #A48736;
}
#main h3 {
margin: 0;
padding: 0;
}
#main p {
margin: 0px 0 1.2em 0;
}
#main code {
font-size: 1.1em;
}
#main form {
margin: 0 0 15px 0;
}
/**
* Footer
*/
#footer {
clear: both;
margin: 0;
padding: 0 8% 0 8%;
color: #BBB;
font-size: 0.8em;
/* ie5win damn hack */
width: 100%;
}
html>body #footer {
width: 84%;
}
/**
* Languages
*/
#languages {
margin: 0;
padding: 0;
float: left;
text-align: left;
width: 60%;
}
#languages div.container {
margin: 0 0 12px 0;
}
#languages h3 {
margin: 0;
padding: 0;
color: #CCC;
font-size: 1.0em;
font-weight: normal;
}
#languages ul {
margin: 0;
padding: 0;
list-style: none;
}
#languages li {
display: inline;
margin: 0;
padding: 0 5px 0 0;
list-style: none;
}
/**
* Footnotes
*/
#footnote {
margin: 0 0 12px 0;
padding: 0;
float: right;
text-align: right;
width: 40%;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@ -14,9 +14,9 @@
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
source "`dirname $0`/variables" source "$(dirname $0)/variables"
LC_ALL=C LC_ALL=C
ODD_CHARS='<27>' ODD_CHARS='<27>'
@ -35,60 +35,61 @@ for BRANCH in $BRANCHES; do
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head> <head>
<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\" /> <meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\" />
<link rel=\"shortcut icon\" type=\"image/png\" href=\"http://www.wesnoth.org/mw/skins/glamdrol/ico.png\" />
<title>Battle for Wesnoth</title> <title>Battle for Wesnoth</title>
<style type=\"text/css\">@import url('images/main.css');</style> <link rel=\"stylesheet\" type=\"text/css\" href=\"https://www.wesnoth.org/wesmere/css/wesmere-1.1.0.css\" />
<link rel=\"stylesheet\" type=\"text/css\" href=\"images/old.css\" /> <link rel=\"stylesheet\" type=\"text/css\" href=\"https://www.wesnoth.org/wesmere/css/gettext-1.1.0.css\" />
</head> </head>
<body> <body>
<div id=\"global\">
<div id=\"header\">
<div id=\"logo\">
<a href=\"http://www.wesnoth.org/\"><img alt=\"Wesnoth logo\" src=\"images/wesnoth-logo.jpg\" /></a>
</div>
</div>
<div id=\"main\">
<div id=\"nav\" role=\"banner\">
<div class=\"centerbox\">
<div id=\"logo\">
<a href=\"https://www.wesnoth.org/\" aria-label=\"Wesnoth logo\"></a>
</div>
<div id=\"nav\"> <div id=\"nav\">
<ul> <ul>
<li><a href=\"http://www.wesnoth.org/\">Home</a></li> <li><a href=\"https://www.wesnoth.org/\">Home</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Play\">Play</a></li> <li><a href=\"https://www.wesnoth.org/wiki/Play\">Play</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Create\">Create</a></li> <li><a href=\"https://www.wesnoth.org/wiki/Create\">Create</a></li>
<li><a href=\"http://www.wesnoth.org/forum/\">Forums</a></li> <li><a href=\"https://www.wesnoth.org/forum/\">Forums</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Support\">Support</a></li> <li><a href=\"https://www.wesnoth.org/wiki/Support\">Support</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Project\">Project</a></li> <li><a href=\"https://www.wesnoth.org/wiki/Project\">Project</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Credits\">Credits</a></li> <li><a href=\"https://www.wesnoth.org/wiki/Credits\">Credits</a></li>
</ul> </ul>
</div> </div>
</div>
</div>
</div>
<h2 style=\"display:inline\">Wesnoth translation stats</h2> <h1 style=\"display:inline\">Wesnoth translation stats</h1>
<div> <br/> </div><p style=\"display:inline\">Last update: <strong> <div> <br/> </div><p style=\"display:inline\">Last update: <strong>
`LC_TIME="en_US.UTF-8" date` $(LC_TIME="en_US.UTF-8" date)
</strong></p> </strong></p>
<div> <br/> </div> <div> <br/> </div>
<table class=\"main\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td> <table class=\"gettext-stats\">
<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" width=\"100%\"> <thead><thead><tr>
<tr class=\"header\"> <th class=\"title\" scope=\"col\">Textdomain</th>
<td class=\"title\">File</td> <th scope=\"col\">Status</th>
<td class=\"title\" align=\"center\">Status</td> <th class=\"translated\" scope=\"col\">Translated</th>
<td class=\"translated\">translated</td> <th class=\"translated percent\" scope=\"col\">%</th>
<td class=\"translated\"><strong>%</strong></td> <th class=\"fuzzy\" scope=\"col\">Fuzzy</th>
<th class=\"fuzzy percent\" scope=\"col\">%</th>
<td class=\"fuzzy\"><strong>fuzzy</strong></td> <th class=\"untranslated\" scope=\"col\">Untranslated</th>
<td class=\"fuzzy\"><strong>%</strong></td> <th class=\"untranslated percent\" scope=\"col\">%</th>
<td class=\"untranslated\"><strong>untranslated</strong></td> <th class=\"strcount\" scope=\"col\">Total</th>
<td class=\"untranslated\"><strong>%</strong></td> <th class=\"graph\" scope=\"col\">Graph</th></tr></thead>
<td class=\"title\">total</td> <tbody><tr>" >> $STATSFILE
<td class=\"title\">graph</td>
</tr>" >> $STATSFILE
for files in $BRANCH/*.po; do for files in $BRANCH/*.po; do
file=`basename $files` file=$(basename $files)
filename=`basename $file .po` filename=$(basename $file .po)
npo=$(($npo + 1)); has_errors="no"; has_warnings="no"; npo=$(($npo + 1)); has_errors="no"; has_warnings="no";
# Extract the declared charset, may be we use this in future. # Extract the declared charset, may be we use this in future.
charset=`sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' "$BRANCH/$file"` charset=$(sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' "$BRANCH/$file")
echo -n "Checking $file for UTF-8 inconsistencies... " echo -n "Checking $file for UTF-8 inconsistencies... "
if $ISUTF8 < "$BRANCH/$file" > /dev/null 2>&1; then if $ISUTF8 < "$BRANCH/$file" > /dev/null 2>&1; then
@ -140,22 +141,22 @@ for BRANCH in $BRANCHES; do
STATUS="Error" STATUS="Error"
fi fi
else else
stat=`LC_MESSAGES=C $MSGFMT --statistics -o /dev/null "$BRANCH/$file" 2>&1` stat=$(LC_MESSAGES=C $MSGFMT --statistics -o /dev/null "$BRANCH/$file" 2>&1)
t=`echo "$stat" | sed -ne 's/\([0-9]\+\) translated .*/\1/p'`; t=${t:-0} t=$(echo "$stat" | sed -ne 's/\([0-9]\+\) translated .*/\1/p'); t=${t:-0}
u=`echo "$stat" | sed -ne 's/.* \([0-9]\+\) untranslated .*/\1/p'`; u=${u:-0} u=$(echo "$stat" | sed -ne 's/.* \([0-9]\+\) untranslated .*/\1/p'); u=${u:-0}
f=`echo "$stat" | sed -ne 's/.* \([0-9]\+\) fuzzy translation.*/\1/p'`; f=${f:-0} f=$(echo "$stat" | sed -ne 's/.* \([0-9]\+\) fuzzy translation.*/\1/p'); f=${f:-0}
sum=$(($t + $f + $u)) sum=$(($t + $f + $u))
if [ ! "$sum" -eq 0 ]; then if [ ! "$sum" -eq 0 ]; then
rt=`printf '%s%d%s%d\n' "scale=2; 100*" $t "/" $sum | bc` rt=$(printf '%s%d%s%d\n' "scale=2; 100*" $t "/" $sum | bc)
fi fi
if [ ! "$sum" -eq 0 ]; then if [ ! "$sum" -eq 0 ]; then
rf=`printf '%s%d%s%d\n' "scale=2; 100*" $f "/" $sum | bc` rf=$(printf '%s%d%s%d\n' "scale=2; 100*" $f "/" $sum | bc)
fi fi
if [ ! "$sum" -eq 0 ]; then if [ ! "$sum" -eq 0 ]; then
ru=`printf '%s%d%s%d\n' "scale=2; 100*" $u "/" $sum | bc` ru=$(printf '%s%d%s%d\n' "scale=2; 100*" $u "/" $sum | bc)
fi fi
nt=$(($nt + $t)); nu=$(($nu + $u)); nf=$(($nf + $f)) nt=$(($nt + $t)); nu=$(($nu + $u)); nf=$(($nf + $f))
@ -172,19 +173,19 @@ for BRANCH in $BRANCHES; do
echo "<tr class=\"row-$CL\">" >> $STATSFILE echo "<tr class=\"row-$CL\">" >> $STATSFILE
CL=$(( ($CL+1)%2 )) CL=$(( ($CL+1)%2 ))
echo " <td align=\"left\"><strong><a href=\""$BRANCH/$filename.po"\">`basename $filename`</a></strong></td> echo " <td class=\"textdomain-name\" align=\"left\"><strong><a href=\""$BRANCH/$filename.po"\">$(basename $filename)</a></strong></td>
<td class=\"percentage-$CL\" align=\"center\">$st</td> <td align=\"center\">$st</td>
<td class=\"row-$CL\" align=\"right\">$t</td>" >> $STATSFILE <td class=\"translated\" align=\"right\">$t</td>" >> $STATSFILE
printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rt "</td>" >> $STATSFILE printf '%s%.2f%s\n' " <td class=\"percent\" align=\"right\">" $rt "</td>" >> $STATSFILE
echo " <td class=\"row-$CL\" align=\"right\">$f</td>" >> $STATSFILE echo " <td class=\"fuzzy\" align=\"right\">$f</td>" >> $STATSFILE
printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rf "</td>" >> $STATSFILE printf '%s%.2f%s\n' " <td class=\"percent\" align=\"right\">" $rf "</td>" >> $STATSFILE
echo " <td class=\"row-$CL\" align=\"right\">$u</td>" >> $STATSFILE echo " <td class=\"untranslated\" align=\"right\">$u</td>" >> $STATSFILE
printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $ru "</td>" >> $STATSFILE printf '%s%.2f%s\n' " <td class=\"percent\" align=\"right\">" $ru "</td>" >> $STATSFILE
echo " <td class=\"row-$CL\" align=\"right\">$sum</td>" >> $STATSFILE echo " <td class=\"strcount\" align=\"right\">$sum</td>" >> $STATSFILE
n4=`printf '%s%f\n' "scale=2; 3*" $rt | bc` n4=$(printf '%s%f\n' "scale=2; 9*" $rt | bc)
n6=`printf '%s%f\n' "scale=2; 3*" $rf | bc` n6=$(printf '%s%f\n' "scale=2; 9*" $rf | bc)
n8=`printf '%s%f\n' "scale=2; 3*" $ru | bc` n8=$(printf '%s%f\n' "scale=2; 9*" $ru | bc)
printf '%s%.2f%s%.2f%s%.2f%s\n' " <td><img src=\"images/green.png\" height=\"15\" width=\"" $n4 "\" alt=\"translated\"/><img src=\"images/blue.png\" height=\"15\" width=\"" $n6 "\" alt=\"fuzzy\"/><img src=\"images/red.png\" height=\"15\" width=\"" $n8 "\" alt=\"untranslated\"/></td>" >> $STATSFILE printf '%s%.2f%s%.2f%s%.2f%s\n' " <td class=\"graph\"><span class=\"stats-bar green-bar\" style=\"width:" $n4 "px\"></span><span class=\"stats-bar blue-bar\" style=\"width:" $n6 "px\"></span><span class=\"stats-bar red-bar\" style=\"width:" $n8 "px\"></span></td>" >> $STATSFILE
echo "</tr>" >> $STATSFILE echo "</tr>" >> $STATSFILE
done done
@ -217,26 +218,27 @@ for BRANCH in $BRANCHES; do
echo "" echo ""
else else
sum=$((${nt} + ${nf} + ${nu})) sum=$((${nt} + ${nf} + ${nu}))
nrt=`printf '%s%d%s%d\n' "scale=2; 100*" $nt "/" $sum | bc` nrt=$(printf '%s%d%s%d\n' "scale=2; 100*" $nt "/" $sum | bc)
nrf=`printf '%s%d%s%d\n' "scale=2; 100*" $nf "/" $sum | bc` nrf=$(printf '%s%d%s%d\n' "scale=2; 100*" $nf "/" $sum | bc)
nru=`printf '%s%d%s%d\n' "scale=2; 100*" $nu "/" $sum | bc` nru=$(printf '%s%d%s%d\n' "scale=2; 100*" $nu "/" $sum | bc)
echo "<tr class=\"title\"> echo "<tfoot><tr class=\"teamstats\">
<td align=\"left\"><strong>Total</strong></td> <th class=\"title\" scope=\"row\">Total</th>
<td align=\"center\"><strong>$STATUS</strong></td> <td align=\"center\">$STATUS</td>
<td align=\"right\"><strong>$nt</strong></td>" >> $STATSFILE <td class=\"translated\">$nt</td>" >> $STATSFILE
printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrt "</strong></td>" >> $STATSFILE printf '%s%.2f%s\n' "<td align=\"right\">" $nrt "</td>" >> $STATSFILE
echo "<td align=\"right\"><strong>$nf</strong></td>" >> $STATSFILE echo "<td class=\"fuzzy\">$nf</td>" >> $STATSFILE
printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrf "</strong></td>" >> $STATSFILE printf '%s%.2f%s\n' "<td align=\"right\">" $nrf "</td>" >> $STATSFILE
echo "<td align=\"right\"><strong>$nu</strong></td>" >> $STATSFILE echo "<td class=\"untranslated\">$nu</td>" >> $STATSFILE
printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nru "</strong></td>" >> $STATSFILE printf '%s%.2f%s\n' "<td align=\"right\">" $nru "</td>" >> $STATSFILE
echo "<td align=\"right\"><strong>$((${nt} + ${nf} + ${nu}))</strong></td>" >> $STATSFILE echo "<td class=\"strcount\">$((${nt} + ${nf} + ${nu}))</td>" >> $STATSFILE
nrt=`printf '%s%f\n' "scale=2; 3*" $nrt | bc` nrt=$(printf '%s%f\n' "scale=2; 9*" $nrt | bc)
nrf=`printf '%s%f\n' "scale=2; 3*" $nrf | bc` nrf=$(printf '%s%f\n' "scale=2; 9*" $nrf | bc)
nru=`printf '%s%f\n' "scale=2; 3*" $nru | bc` nru=$(printf '%s%f\n' "scale=2; 9*" $nru | bc)
printf '%s%.2f%s%.2f%s%.2f%s\n' "<td><img src=\"images/green.png\" height=\"15\" width=\"" $nrt "\" alt=\"translated\"/><img src=\"images/blue.png\" height=\"15\" width=\"" $nrf "\" alt=\"fuzzy\"/><img src=\"images/red.png\" height=\"15\" width=\"" $nru "\" alt=\"untranslated\"/></td>" >> $STATSFILE printf '%s%.2f%s%.2f%s%.2f%s\n' " <td class=\"graph\"><span class=\"stats-bar green-bar\" style=\"width:" $nrt "px\"></span><span class=\"stats-bar blue-bar\" style=\"width:" $nrf "px\"></span><span class=\"stats-bar red-bar\" style=\"width:" $nru "px\"></span></td>" >> $STATSFILE
echo "</tr> echo "</tr>
</table> </table>
</td> </td>
@ -245,7 +247,8 @@ for BRANCH in $BRANCHES; do
<div><br/></div> <div><br/></div>
<div id=\"footer\"> <div id=\"footer\">
<div id=\"footnote\"> <div id=\"footnote\">
&copy; 2003-"`date +%Y`" The Battle for Wesnoth<br/> &copy; 2003-"$(date +%Y)" The Battle for Wesnoth<br/>
Site design Copyright © 20172018 by Iris Morelle.
<br/> <br/>
</div> </div>
</div> </div>