3 # This quick hack gives translation statistics (from the core translation
6 # Copyright (C) 2001, Cyrille Chepelov <chepelov@calixo.net>
8 # This quick hack is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This quick hack is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this quick hack; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 import string
,os
,sys
,math
28 if n
is None: return (" " * maxlanglen
)
32 """returns a tuple (language_name,ids,translations) of what has
34 base
,ext
= os
.path
.splitext(os
.path
.basename(fname
))
53 if s
.find('fuzzy') >= 0:
56 s
= string
.strip(string
.split(s
,'#')[0])
57 if not s
: continue # empty or comment line.
61 #print "id",id,"st",st
65 translations
= translations
+ 1
69 elif sl
[0] == "msgstr":
70 #print "id",id,"st",st
82 #print "translations:",translations,"idents:",idents
83 return (language_name
, idents
, translations
,fuzzies
)
86 print "Usage: %s <package.pot> <lang.po> ..." % sys
.argv
[0]
88 print " <package.pot>: file name of the identifier reference to check."
89 print " <lang.po>: file name of the translation to check"
97 (t
,idents
,n
,f
) = slurp_po(sys
.argv
[1])
100 translations
= map(slurp_po
,sys
.argv
[2:])
101 trans
= map(lambda (l
,i
,t
,f
),ti
=idents
:
102 "%s:%3d%%(%d/%d/%d)%s"%(l
,
105 "*" * (idents
!= i
)),
107 maxlanglen
= len(reduce(maxlen
,trans
,""))
108 trans
= map(lambda s
,mll
=maxlanglen
: string
.ljust(s
,mll
),trans
)
110 collen
= maxlanglen
+ len(" ")
112 numcols
= int(79 / collen
)
113 ltnc
= (len(trans
) / numcols
) + (len(trans
) % numcols
)
117 c
,trans
= trans
[:ltnc
],trans
[ltnc
:]
120 lines
= apply(map,tuple([None]+cols
))
122 result
= string
.join(map(lambda l
:string
.join(map(NoneStr
,list(l
))," "),