#!/bin/bash # # -*-sh-*- # # Copyright (C) 2004-2005 Davide Viti # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this program; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # usage() { echo "Usage:" echo "$0 " } if [ -z "$1" ] ; then usage exit 1 fi if [ -z "$2" ] ; then usage exit 1 fi STATS=$1 TEMPLATE=$2 INDEX_HTML=$3 TABLE_HTML=`mktemp` # Compute some statistics i=0 TOTAL=0 AVERAGE=0 UNIQUE_CODEPOINTS=0 for VAL in `sort -n ${STATS} | awk '{print $2}'`; do if [ ${VAL} -ne -1 ] ; then TOTAL=$((${TOTAL} + ${VAL})) i=$((i+1)) fi done # avoid division by 0 if [ $i -ne 0 ] ; then AVERAGE=$((${TOTAL} / $i)) fi TOTAL_VARS=0 for VAL in `awk '{print $3}' ${STATS}`; do if [ ${VAL} -gt 0 ] ; then TOTAL_VARS=$((${TOTAL_VARS} + ${VAL})) fi done TOTAL_SPECIFIC=0 for VAL in `awk '{print $5}' ${STATS}`; do if [ ${VAL} -gt 0 ] ; then TOTAL_SPECIFIC=$((${TOTAL_SPECIFIC} + ${VAL})) fi done LOGFILE=${TABLE_HTML} exec 6>&1 # Link file descriptor #6 with stdout. # Saves stdout. exec > ${LOGFILE} # stdout replaced with file "logfile.txt". # create HTML table echo "" echo " " echo " " echo " " echo " " if [ ${HANDLE_SUSPECT_VARS} = "yes" ] ; then echo " " fi echo " " echo " " echo " " echo " " echo " " # fill the table: # Lang, Unkn words, Msg, List of unknown words, Susp vars, Custom wl, codepoints, All Files for ROW in `sed "s: :,:g" ${STATS}`; do LANG=`echo ${ROW} | awk -F, '{print $1}'` UNKN=`echo ${ROW} | awk -F, '{print $2}'` CODEPOINTS=`echo ${ROW} | awk -F, '{print $4}'` SPECIFIC_VARS=`echo ${ROW} | awk -F, '{print $5}'` ISO_CODE=`grep -w "^${LANG}" ${CFG_DIR}/iso_codes.txt | awk -F, '{print $2}'` if [ ${HANDLE_SUSPECT_VARS} = "yes" ] ; then SUSP=`echo ${ROW} | awk -F, '{print $3}'` if [ ${SUSP} -gt 0 ] ; then SUSPECT_VARS_URL="${SUSP}" else SUSPECT_VARS_URL="-" fi fi if [ ${SPECIFIC_VARS} -gt 0 ] ; then SPECIFIC_CHECK_URL="${SPECIFIC_VARS}" else SPECIFIC_CHECK_URL="-" fi if [ -f ${WLS_PATH}/${LANG}_wl.txt ] ; then WORDLIST="${LANG}_wl.txt" else WORDLIST="-" fi echo " " echo " " # Number of unknown words if [ ${UNKN} -eq -1 ] ; then echo " " elif [ ${UNKN} -eq 0 ] ; then echo " " else if [ -f ${DIFF_DIR}/nozip/${LANG}_unkn_wl.diff ] ; then DIFF=" (*)" else DIFF= fi echo " " fi if [ -f ${DIFF_DIR}/nozip/${LANG}_all.diff ] ; then DIFF=" (*)" else DIFF= fi echo " " # Suspect Variables if [ ${HANDLE_SUSPECT_VARS} = "yes" ] ; then SUSP_PATH=${SUSPECT_VARS_URL/latest/} if [ -f ${DIFF_DIR}/nozip/${LANG}_var.diff ] ; then DIFF=" (*)" else DIFF= fi echo " " fi # Specific check if [ -f ${DIFF_DIR}/nozip/${LANG}_lspec.diff ] ; then DIFF=" (*)" else DIFF= fi echo " " echo " " if [ ${CODEPOINTS} -eq 0 ] ; then echo " " else echo " " fi echo " " echo " " done # Total unknown words echo " " echo " " echo " " echo " " if [ ${HANDLE_SUSPECT_VARS} = "yes" ] ; then echo " " fi echo " " echo " " echo " " echo " " echo " " # Average unknown words per language echo " " echo " " echo " " echo " " if [ ${HANDLE_SUSPECT_VARS} = "yes" ] ; then echo " " fi echo " " echo " " echo " " echo " " echo " " echo "
LanguageUnknown wordsMessagesSuspect variablesSpecific checksCustom wordlistCodepointsAll files
${ISO_CODE} [${LANG}]-0${UNKN}${DIFF}${LANG}_all.txt${DIFF}${SUSPECT_VARS_URL}${DIFF}${SPECIFIC_CHECK_URL}${DIFF}${WORDLIST}-${CODEPOINTS}${LANG}.tar.gz
TOTAL${TOTAL}-${TOTAL_VARS}${TOTAL_SPECIFIC}
AVERAGE${AVERAGE}
" exec 1>&6 6>&- # Restore stdout and close file descriptor #6. sed -e "//r ${TABLE_HTML}" \ -e "s||$(date --utc)|" \ -e "s||latest/nozip/di_common_wl.txt|" \ -e "s||latest/zip/codepoints.tar.gz|" \ -e "s||latest/zip/all_strings.tar.gz|" \ -e "s||latest/all_codes.txt|" \ ${TEMPLATE} > ${INDEX_HTML} # Remove file in /tmp rm ${TABLE_HTML}