#!/bin/bash
[ -f ~/.d-i_manual_daily ] || exit 1
. ~/.d-i_manual_daily
mainlog=$logdir/main.log
pagefile=$destination/index.html
[ -f "$ROOT/bin/langlist" ] || exit 1
[ -f "$ROOT/bin/archlist" ] || exit 1
build_link_table () {
# Count languages
num_lang=0
for lang in $languages; do
num_lang=$(($num_lang + 1))
done
echo "
Links per architecture/language
" >>$pagefile
echo "" >>$pagefile
echo "" >>$pagefile
echo " " >>$pagefile
echo " Architecture | " >>$pagefile
for lang in $languages ; do
langname=$(egrep "^$lang[[:space:]]" $ROOT/bin/langlist | cut -f 7)
echo " $langname | " >>$pagefile
done
echo "
" >>$pagefile
for arch in $architectures ; do
archname=$(egrep "^$arch[[:space:]]" $ROOT/bin/archlist | cut -f 2)
echo "" >>$pagefile
echo " " >>$pagefile
echo " $archname | " >>$pagefile
for lang in $languages ; do
langname=$(egrep "^$lang[[:space:]]" $ROOT/bin/langlist | cut -f 7)
destsuffix="${lang}.${arch}"
echo " " >>$pagefile
echo " html" >>$pagefile
SEP=" "
if [ "$(egrep "^$lang[[:space:]]" $ROOT/bin/langlist | cut -f 4)" = "Y" ] ; then
echo " $SEPpdf" >>$pagefile
SEP=""
fi
if [ "$(egrep "^$lang[[:space:]]" $ROOT/bin/langlist | cut -f 6)" = "Y" ] ; then
echo " $SEPtext" >>$pagefile
fi
echo " | " >>$pagefile
done
echo "
" >>$pagefile
done
echo "" >>$pagefile
echo "
" >>$pagefile
}
# MAINLINE
# No longer calculate statistics for xml-based languages here, to avoid xml statistics
# for po-based languages. Is now in build-manual line 360. holgerw
#echo "- calculating translation statistics for XML-based translations..." >>$mainlog
#$ROOT/bin/translation-stats | sort -k 2,2nr >$logdir/tr-stats
echo "- calculating translation statistics for PO-based translations..." >>$mainlog
$ROOT/bin/po_stats/gen &>$logdir/po-stats.log
echo "- assembling page..." >>$mainlog
cat $ROOT/bin/index.head >$pagefile
# First, we build the table for the languages that have all architectures built
# Order of languages is alphabetic by name, but keep English first.
languages=$(egrep -v "^[[:space:]]*(|#.*)$" $ROOT/bin/langlist | \
sed "s/English/0English/" | sort -k 7,7 | \
cut -f 1,2 | egrep "Y$" | cut -f 1)
# Order of architectures is alphabetic by name.
architectures=$(egrep -v "^[[:space:]]*(|#.*)$" $ROOT/bin/archlist | \
sort -k 2,2 | cut -f 1)
build_link_table
cat $ROOT/bin/index.single >>$pagefile
# Next, we build the table for the languages that have only i386 built
# Order of languages is alphabetic by name.
languages=$(egrep -v "^[[:space:]]*(|#.*)$" $ROOT/bin/langlist | sort -k 7,7 |
cut -f 1,2 | egrep "S$" | cut -f 1)
# Order of architectures is alphabetic by name.
architectures="i386"
build_link_table
if [ -f $logdir/tr-stats ] ; then
cat $ROOT/bin/index.stats >>$pagefile
echo "" >>$pagefile
echo "" >>$pagefile
echo " " >>$pagefile
echo " Language | " >>$pagefile
echo " % complete | " >>$pagefile
echo " Translated files | " >>$pagefile
echo " Untranslated files | " >>$pagefile
echo " Files needing update | " >>$pagefile
echo " Missing files | " >>$pagefile
echo "
" >>$pagefile
# Statistics for XML-based translations
for lang in $(egrep -v "^en" $logdir/tr-stats | cut -f 1) ; do
# XML-based if language dir has been committed to SVN
if [ -d "$source/$lang/" ] ; then
langname=$(egrep "^$lang[[:space:]]" $ROOT/bin/langlist | cut -f 7)
echo " " >>$pagefile
echo " $langname | " >>$pagefile
for col in 2 4 6 9 8 ; do
value=$(egrep "^$lang[[:space:]]" $logdir/tr-stats | cut -f $col)
echo " $value | " >>$pagefile
done
echo "
" >>$pagefile
fi
done
echo "" >>$pagefile
echo "
" >>$pagefile
# Statistics for PO-based translations
cat $ROOT/bin/index.pohead >>$pagefile
cat $ROOT/bin/index.podata >>$pagefile
fi
sed "s/%date%/$(date -u)/; s/%email%/$MAIL_FROM/g" $ROOT/bin/index.tail >>$pagefile
cp $ROOT/bin/translators.html $destination
chmod 664 $destination/translators.html
rm -f $ROOT/bin/index.podata
exit 0