Comment fact fix: header has moved.
[freeciv.git] / translations / stats.sh
blobd97d128baa7009d5aa0e8b0c89cbaa03c4ace0f9
1 #!/bin/bash
2 #/**********************************************************************
3 # Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 #***********************************************************************/
16 SRCDIR="$(dirname "$0")"
18 dir_stats() {
19 declare -i TRANS
20 declare -i FUZZY
21 declare -i UNTRANS
22 declare -i SUM
23 declare -i PRCT
25 for POFILE in $@
27 if test "x$POFILE" != "x" ; then
28 CODE=$(echo "$POFILE" | sed -e 's/.po//' -e 's,.*/,,' -e 's,.*\\,,')
29 FSTR="$(LANG=C msgfmt --stat "$POFILE" 2>&1)"
30 if echo $FSTR | grep translated >/dev/null ; then
31 TRANS=$(echo $FSTR | sed 's/ translated.*//')
32 FSTR="$(echo $FSTR | sed 's/.* translated messages*[.,]//')"
33 else
34 TRANS=0
36 if echo $FSTR | grep fuzzy >/dev/null ; then
37 FUZZY=$(echo $FSTR | sed 's/ fuzzy.*//')
38 FSTR="$(echo $FSTR | sed 's/.* fuzzy translations*[.,]//')"
39 else
40 FUZZY=0
42 if echo $FSTR | grep untranslated >/dev/null ; then
43 UNTRANS=$(echo $FSTR | sed 's/ untranslated.*//')
44 else
45 UNTRANS=0
48 SUM=$TRANS+$FUZZY+$UNTRANS
49 PRCT=$TRANS*100/$SUM
51 echo "$CODE $PRCT%"
53 done
56 if test "x$1" = "x-h" || test "x$1" = "x--help" ; then
57 echo "Usage: $(basename $0) [domain=all]"
58 exit
61 if test "x$1" != "x" && test "x$1" != "xall" ; then
62 DOMAINLIST="$1"
63 else
64 DOMAINLIST="core nations ruledit"
67 for domain in $DOMAINLIST
69 if test "x$1" = "x" ; then
70 echo
71 echo "$domain"
72 echo "----------"
75 dir_stats "$SRCDIR/$domain/*.po"
76 rm messages.mo
77 done