From 2e727616ce2c2154aba9150beb9a06f20e4b15d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nick=20=C3=98stergaard?= Date: Mon, 1 Aug 2016 23:59:48 +0200 Subject: [PATCH] Add improved statistics for the update po files script --- update-po-files.sh | 48 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/update-po-files.sh b/update-po-files.sh index 8604fb0df6..48007b2a62 100755 --- a/update-po-files.sh +++ b/update-po-files.sh @@ -1,15 +1,17 @@ -#!/bin/bash +#!/bin/bash -e ##################################### # # This program source code file is part of KiCad, a free EDA CAD application. # # Copyright (C) 2015 Marco Ciampa -# Copyright (C) 2015 KiCAd Developers +# Copyright (C) 2015-2016 KiCAd Developers # # License GNU GPL Version 3 or any later version. # ##################################### +LANG=C + if [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then echo "Usage: $0 [-k] [locale]" echo @@ -22,7 +24,11 @@ if [ "$1" = "-k" ] ; then shift fi -SOURCEDIR=../kicad-source-mirror #Set this first!!! +if [ -z ${SOURCEDIR} ]; then + SOURCEDIR=../kicad-source-mirror + echo "Using default SOURCEDIR=${SOURCEDIR}" +fi +CSVFILE=${PWD}/i18n_status.csv #Autovars LOCALDIR=$PWD @@ -58,10 +64,42 @@ if [ ! "$1" = "" ] ; then fi fi +echo "Writing summary to ${CSVFILE}" +echo "LANG;TRANSLATED;FUZZY;UNTRANSLATED" > "${CSVFILE}" + for i in $LINGUAS do - msgmerge --force-po $LOCALDIR/$i/kicad.po $LOCALDIR/kicad.pot -o $LOCALDIR/$i/kicad.po 2>&1 # >> /dev/null - msgfmt --statistics $LOCALDIR/$i/kicad.po 2>&1 >>/dev/null + echo "## $i" + msgmerge --force-po $LOCALDIR/$i/kicad.po $LOCALDIR/kicad.pot -o $LOCALDIR/$i/kicad.po 2> /dev/null + msgfmt --statistics $LOCALDIR/$i/kicad.po 2>&1 >>/dev/null | + while IFS=",." read A B C D ; do + echo $A + echo $B + echo $C + echo $D + + for STRING in "$A" "$B" "$C" "$D" ; do + STRING=${STRING# } + case "$STRING" in + *" translated message"* ) + TRANSLATED=${STRING% translated message*} + ;; + *" fuzzy translation"* ) + FUZZY=${STRING% fuzzy translation*} + ;; + *" untranslated message"* ) + UNTRANSLATED=${STRING% untranslated message*} + ;; + "" ) + ;; + * ) + echo >&2 "$0: Unknown format of \"msgfmt --statistics $LOCALDIR/$i/kicad.po \": \"$STRING\"" + exit 1 + ;; + esac + done + echo "$i;${TRANSLATED};${FUZZY};${UNTRANSLATED}">>"${CSVFILE}" + done done if [ ! "$KEEP" = "1" ]; then