#!/bin/bash
#
# script originally by Pedro Lopez-Cabanillas; adapted to Qt4 by D. Michael
# McIntyre
#
# no license was specified, so GPL is assumed
unset LC_MESSAGES
unset LANG
puke() {
echo $1
exit 1
}
cd data/locale || puke "This script must run from the rosegarden/ directory."
if [ "x$(basename $(pwd))" != "xlocale" -o $(ls *.ts 2>/dev/null|wc -w) -eq 0 ]; then
echo "Current directory doesn't seem to have any translations."
echo "Please, use this script from inside the locale/ directory."
exit 1
fi
STATS=""
TRANSLATED=0
UNFINISHED=0
UNTRANSLATED=0
COMPLETION=0
TOTAL=0
OBSOLETE=0
function getValues() {
# analyze the file's strings with grep and friends, since I can't find a
# program whose output to parse to produce these statistics the way Pedro's
# original version of this script used msgfmt
# Ah. When the translation is exactly the same as the original (a lot of
# "%1 %2" kind of stuff, and "Solo" in English and Spanish) then no
# translation is stored, so these were counting as untranslated unfairly.
#
# Anything with should be translated and
# finished, but anything with
# is unfinished. That settles that, I think. I hope.
UNTRANSLATED=$(grep "" $1 | wc -l | cut -d \ -f 1)
UNFINISHED=$(grep "" $1 | wc -l | cut -d \ -f 1)
TRANSLATED=$(grep ".\+<" $1 | wc -l | cut -d \ -f 1)
TOTAL=$(grep "" $1 | wc -l | cut -d \ -f 1)
COMPLETION=$((($UNFINISHED*5)/$TOTAL))
((COMPLETION = 5 - COMPLETION - 1))
OBSOLETE=$(grep "