Browse Source

Simplify echo code

master
Andrius Štikonas 11 years ago
parent
commit
b93bb5328e
1 changed files with 85 additions and 82 deletions
  1. +85
    -82
      statistics.sh

+ 85
- 82
statistics.sh View File

@@ -40,59 +40,58 @@ for BRANCH in $TRUNK $BRANCHES; do
nerror=0; nwarn=0; npo=0; nt=0; nu=0; nf=0
rm -f $STATSFILE

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"" >> $STATSFILE
echo "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" >> $STATSFILE
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">" >> $STATSFILE
echo "<head>" >> $STATSFILE
echo " <meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\" />" >> $STATSFILE
echo " <link rel=\"shortcut icon\" type=\"image/png\" href=\"http://www.wesnoth.org/mw/skins/glamdrol/ico.png\" />" >> $STATSFILE
echo " <style type=\"text/css\">@import url('http://www.wesnoth.org/mw/skins/glamdrol/main.css');</style>" >> $STATSFILE
echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"http://gettext.wesnoth.org/styles/old.css\" />" >> $STATSFILE
echo " <title>Battle for Wesnoth</title>" >> $STATSFILE
echo "</head>" >> $STATSFILE
echo "<body>" >> $STATSFILE
echo "" >> $STATSFILE
echo "<div id=\"global\">" >> $STATSFILE
echo "<div id=\"header\">" >> $STATSFILE
echo " <div id=\"logo\">" >> $STATSFILE
echo " <a href=\"http://www.wesnoth.org/\"><img alt=\"Wesnoth logo\" src=\"http://www.wesnoth.org/mw/skins/glamdrol/wesnoth-logo.jpg\" /></a>" >> $STATSFILE
echo " </div>" >> $STATSFILE
echo "</div>" >> $STATSFILE
echo "" >> $STATSFILE
echo "<div id=\"nav\">" >> $STATSFILE
echo "<ul>" >> $STATSFILE
echo " <li><a href=\"http://www.wesnoth.org/\">Home</a></li>" >> $STATSFILE
echo " <li><a href=\"http://www.wesnoth.org/wiki/Play\">Play</a></li>" >> $STATSFILE
echo "" >> $STATSFILE
echo " <li><a href=\"http://www.wesnoth.org/wiki/Create\">Create</a></li>" >> $STATSFILE
echo " <li><a href=\"http://www.wesnoth.org/forum/\">Forums</a></li>" >> $STATSFILE
echo " <li><a href=\"http://www.wesnoth.org/wiki/Support\">Support</a></li>" >> $STATSFILE
echo " <li><a href=\"http://www.wesnoth.org/wiki/Project\">Project</a></li>" >> $STATSFILE
echo " <li><a href=\"http://www.wesnoth.org/wiki/Credits\">Credits</a></li>" >> $STATSFILE
echo "</ul>" >> $STATSFILE
echo "</div>" >> $STATSFILE
echo "" >> $STATSFILE
echo "<h2 style=\"display:inline\">Wesnoth translation stats</h2>" >> $STATSFILE
echo "<div> <br/> </div><p style=\"display:inline\">Last update: <strong>" >> $STATSFILE
LC_TIME="en_US.UTF-8" date >> $STATSFILE
echo "</strong></p>" >> $STATSFILE
echo "<div> <br/> </div>" >> $STATSFILE
echo "<table class=\"main\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td>" >> $STATSFILE
echo "<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" width=\"100%\">" >> $STATSFILE
echo "<tr class=\"header\">" >> $STATSFILE
echo "<td class=\"title\">File</td>" >> $STATSFILE
echo "<td class=\"title\" align=\"center\">Status</td>" >> $STATSFILE
echo "<td class=\"translated\">translated</td>" >> $STATSFILE
echo "<td class=\"translated\"><strong>%</strong></td>" >> $STATSFILE
echo "" >> $STATSFILE
echo "<td class=\"fuzzy\"><strong>fuzzy</strong></td>" >> $STATSFILE
echo "<td class=\"fuzzy\"><strong>%</strong></td>" >> $STATSFILE
echo "<td class=\"untranslated\"><strong>untranslated</strong></td>" >> $STATSFILE
echo "<td class=\"untranslated\"><strong>%</strong></td>" >> $STATSFILE
echo "<td class=\"title\">total</td>" >> $STATSFILE
echo "<td class=\"title\">graph</td>" >> $STATSFILE
echo "</tr>" >> $STATSFILE
echo -e "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head>
<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\" />
<style type=\"text/css\">@import url('http://www.wesnoth.org/mw/skins/glamdrol/main.css');</style>
<link rel=\"stylesheet\" type=\"text/css\" href=\"http://gettext.wesnoth.org/styles/old.css\" />
<title>Battle for Wesnoth</title>
</head>
<body>

<div id=\"global\">
<div id=\"header\">
<div id=\"logo\">
<a href=\"http://www.wesnoth.org/\"><img alt=\"Wesnoth logo\" src=\"http://www.wesnoth.org/mw/skins/glamdrol/wesnoth-logo.jpg\" /></a>
</div>
</div>

<div id=\"nav\">
<ul>
<li><a href=\"http://www.wesnoth.org/\">Home</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Play\">Play</a></li>

<li><a href=\"http://www.wesnoth.org/wiki/Create\">Create</a></li>
<li><a href=\"http://www.wesnoth.org/forum/\">Forums</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Support\">Support</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Project\">Project</a></li>
<li><a href=\"http://www.wesnoth.org/wiki/Credits\">Credits</a></li>
</ul>
</div>

<h2 style=\"display:inline\">Wesnoth translation stats</h2>
<div> <br/> </div><p style=\"display:inline\">Last update: <strong>
`LC_TIME="en_US.UTF-8" date`
</strong></p>
<div> <br/> </div>
<table class=\"main\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td>
<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" width=\"100%\">
<tr class=\"header\">
<td class=\"title\">File</td>
<td class=\"title\" align=\"center\">Status</td>
<td class=\"translated\">translated</td>
<td class=\"translated\"><strong>%</strong></td>

<td class=\"fuzzy\"><strong>fuzzy</strong></td>
<td class=\"fuzzy\"><strong>%</strong></td>
<td class=\"untranslated\"><strong>untranslated</strong></td>
<td class=\"untranslated\"><strong>%</strong></td>
<td class=\"title\">total</td>
<td class=\"title\">graph</td>
</tr>" >> $STATSFILE

for dir in `ls $BRANCH/wesnoth* -d`; do
file=$DIR"/"`basename $dir`"."$LCODE".po";
@@ -189,9 +188,9 @@ for BRANCH in $TRUNK $BRANCHES; do

echo "<tr class=\"row-$CL\">" >> $STATSFILE
CL=$(( ($CL+1)%2 ))
echo " <td align=\"left\"><strong>`basename $filename`</strong></td>" >> $STATSFILE
echo " <td class=\"percentage-$CL\" align=\"center\">$st</td>" >> $STATSFILE
echo " <td class=\"row-$CL\" align=\"right\">$t</td>" >> $STATSFILE
echo " <td align=\"left\"><strong>`basename $filename`</strong></td>
<td class=\"percentage-$CL\" align=\"center\">$st</td>
<td class=\"row-$CL\" align=\"right\">$t</td>" >> $STATSFILE
printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rt "</td>" >> $STATSFILE
echo " <td class=\"row-$CL\" align=\"right\">$f</td>" >> $STATSFILE
printf '%s%d%s%.2f%s\n' " <td class=\"percentage-" $CL "\" align=\"right\">" $rf "</td>" >> $STATSFILE
@@ -213,31 +212,35 @@ for BRANCH in $TRUNK $BRANCHES; do
if [ "$nerror" -gt 0 ]; then
echo -n -e "\E[31mFatal errors found. See '"
tput smso; echo -n "$ERRORS"; tput rmso
echo -e "' for details."; tput sgr0
echo -ne "' for details."; tput sgr0
echo ""
else
echo -e "\E[32mNo fatal errors found."; tput sgr0
echo -ne "\E[32mNo fatal errors found."; tput sgr0
echo ""
if [ -s "$ERRORS" ]; then
echo -n -e "\E[31m See '"
tput smso; echo -n "$ERRORS"; tput rmso
echo -e "' for warnings."; tput sgr0
echo -ne "' for warnings."; tput sgr0
echo ""
else
rm -f $ERRORS
fi
fi
if [ "$npo" = "$nerror" ]; then
echo -e "\E[31mAll files have fatal errors."; tput sgr0
echo -en "\E[31mAll files have fatal errors."; tput sgr0
echo ""
else
sum=$((${nt} + ${nf} + ${nu}))
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`
nru=`printf '%s%d%s%d\n' "scale=2; 100*" $nu "/" $sum | bc`
echo "<tr class=\"title\">" >> $STATSFILE
echo "<td align=\"left\"><strong>Total</strong></td>" >> $STATSFILE
echo "<td align=\"center\"><strong>$STATUS</strong></td>" >> $STATSFILE
echo "<td align=\"right\"><strong>$nt</strong></td>" >> $STATSFILE
echo "<tr class=\"title\">
<td align=\"left\"><strong>Total</strong></td>
<td align=\"center\"><strong>$STATUS</strong></td>
<td align=\"right\"><strong>$nt</strong></td>" >> $STATSFILE
printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrt "</strong></td>" >> $STATSFILE
echo "<td align=\"right\"><strong>$nf</strong></td>" >> $STATSFILE
printf '%s%.2f%s\n' "<td align=\"right\"><strong>" $nrf "</strong></td>" >> $STATSFILE
@@ -250,24 +253,24 @@ for BRANCH in $TRUNK $BRANCHES; do
nru=`printf '%s%f\n' "scale=2; 3*" $nru | bc`
printf '%s%.2f%s%.2f%s%.2f%s\n' "<td><img src=\"http://gettext.wesnoth.org/images/green.png\" height=\"15\" width=\"" $nrt "\" alt=\"translated\"/><img src=\"http://gettext.wesnoth.org/images/blue.png\" height=\"15\" width=\"" $nrf "\" alt=\"fuzzy\"/><img src=\"http://gettext.wesnoth.org/images/red.png\" height=\"15\" width=\"" $nru "\" alt=\"untranslated\"/></td>" >> $STATSFILE
echo "</tr>" >> $STATSFILE
echo "</table>" >> $STATSFILE
echo "</td>" >> $STATSFILE
echo "</tr>" >> $STATSFILE
echo "</table>" >> $STATSFILE
echo "<div> <br/> </div>" >> $STATSFILE
echo "<div id=\"footer\">" >> $STATSFILE
echo "" >> $STATSFILE
echo "<div id=\"footnote\">" >> $STATSFILE
echo "&copy; 2003-"`date +%Y`" The Battle for Wesnoth<br/>" >> $STATSFILE
echo "<br/>" >> $STATSFILE
echo "<a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.w3.org/Icons/valid-xhtml11-blue\"" >> $STATSFILE
echo "alt=\"Valid XHTML 1.1!\" height=\"31\" width=\"88\" /></a>" >> $STATSFILE
echo "</div>" >> $STATSFILE
echo "</div>" >> $STATSFILE
echo "</div>" >> $STATSFILE
echo "</body>" >> $STATSFILE
echo "</html>" >> $STATSFILE
echo "</tr>
</table>
</td>
</tr>
</table>
<div> <br/> </div>
<div id=\"footer\">
<div id=\"footnote\">
&copy; 2003-"`date +%Y`" The Battle for Wesnoth<br/>
<br/>
<a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.w3.org/Icons/valid-xhtml11-blue\"
alt=\"Valid XHTML 1.1!\" height=\"31\" width=\"88\" /></a>
</div>
</div>
</div>
</body>
</html>" >> $STATSFILE
fi
done


Loading…
Cancel
Save