Commit b724521c authored by Bruno Coudoin's avatar Bruno Coudoin

added po stats

parent 0c96311a
2003-02-05 Bruno Coudoin <bruno.coudoin@free.fr>
* Makefile.am: added po stats (python tool taken from dia)
* boards/machpuzzle.xml.in: removed until it does something usefull
* po-checktrans: a nive tool from Cyrille Chepelov to get stats on po files
* po-checktrans.py: a nive tool from Cyrille Chepelov to get stats on po files
2003-02-04 Bruno Coudoin <bruno.coudoin@free.fr>
* src/gcompris/config.c: Added "tr" (Turkish) to the languages' list.
......
......@@ -23,7 +23,8 @@ EXTRA_DIST = config.rpath \
gcompris.spec \
intltool-extract.in \
intltool-merge.in \
intltool-update.in
intltool-update.in \
core-translation-report po-checktrans.py po-checktrans
distcore = $(PACKAGE)-core-$(VERSION)
......@@ -41,6 +42,8 @@ dist-hook:
fi
CLEANFILES = core-translation-report gcompris.desktop
clean-local:
rm -f intltool-extract intltool-merge intltool-update
......@@ -56,4 +59,11 @@ dist-core:
gzip --best $(distcore).tar
@echo Created $(distcore).tar.gz
# Display stats on translation
core-translation-report: po/gcompris.pot po-checktrans.py po-checktrans
-(cd $(srcdir) && ./po-checktrans po/gcompris.pot po/*.po)
all-local: core-translation-report
ACLOCAL_AMFLAGS =
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="machpuzzle"
type="machpuzzle"
section="/boards/."
icon="boardicons/erase.png"
difficulty="1"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
boarddir="">
<_title>The incredible machine</_title>
<_description></_description>
<_prerequisite></_prerequisite>
<_goal></_goal>
<_manual>
</_manual>
<_credit>
</_credit>
</Board>
</GCompris>
#!/bin/sh
str=core-translation-report
cat <<__EOF__ >$str
*** PO/core/gettext translation report: ***
(Absence of a language code means 0% translation for that language)
(Help for translations (and/or much more) is of course welcome !)
(A star after a language's statistics means that the translation file isn't
up to date with the POT (original messages) file)
Entry format:
country_code percentage% (translated,fuzzy,total)
translated includes fuzzy entries.
__EOF__
./po-checktrans.py $* >>$str || cat <<__EOF__ >>$str
E: po-checktrans failed to run. Please check that python is installed
E: on your system.
__EOF__
cat $str
exit 0
#!/usr/bin/python
#
# This quick hack gives translation statistics (from the core translation
# files).
#
# Copyright (C) 2001, Cyrille Chepelov <chepelov@calixo.net>
#
# This quick hack 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 quick hack 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 quick hack; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
import string,os,sys,math
collen = 1
def NoneStr(n):
if n is None: return (" " * maxlanglen)
return n
def slurp_po(fname):
"""returns a tuple (language_name,ids,translations) of what has
been translated."""
base,ext = os.path.splitext(os.path.basename(fname))
language_name = base
idents = 0
translations = 0
st = ""
id = ""
fuzzy = 0
prev_fuzzy = 0
fuzzies = 0
fd = open(fname,"r")
while 1:
s = fd.readline()
if not s: break
if s[0] == '#':
if s.find('fuzzy') >= 0:
fuzzy = 1
s = string.strip(string.split(s,'#')[0])
if not s: continue # empty or comment line.
sl = string.split(s)
if sl[0] == "msgid":
#print "id",id,"st",st
if st:
if prev_fuzzy:
fuzzies = fuzzies + 1
translations = translations + 1
id = sl[0]
st = ""
del sl[0]
elif sl[0] == "msgstr":
#print "id",id,"st",st
if st:
idents = idents + 1
id = sl[0]
st = ""
del sl[0]
prev_fuzzy = fuzzy
fuzzy = 0
for k in sl:
if k != '""':
st = st + k
#print "translations:",translations,"idents:",idents
return (language_name, idents, translations,fuzzies)
if len(sys.argv)<3:
print "Usage: %s <package.pot> <lang.po> ..." % sys.argv[0]
print
print " <package.pot>: file name of the identifier reference to check."
print " <lang.po>: file name of the translation to check"
sys.exit(1)
def maxlen(a,b):
if len(a) > len(b):
return a
return b
(t,idents,n,f) = slurp_po(sys.argv[1])
del t,n,f
translations = map(slurp_po,sys.argv[2:])
trans = map(lambda (l,i,t,f),ti=idents:
"%s:%3d%%(%d/%d/%d)%s"%(l,
100*float(t)/idents,
t,f,idents,
"*" * (idents != i)),
translations)
maxlanglen = len(reduce(maxlen,trans,""))
trans = map(lambda s,mll=maxlanglen: string.ljust(s,mll),trans)
collen = maxlanglen + len(" ")
numcols = int(79 / collen)
ltnc = (len(trans) / numcols) + (len(trans) % numcols)
cols = []
while trans:
c,trans = trans[:ltnc],trans[ltnc:]
cols.append(c)
lines = apply(map,tuple([None]+cols))
result = string.join(map(lambda l:string.join(map(NoneStr,list(l))," "),
lines),
"\n")
print result
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment