Updtae
svn: r6149
This commit is contained in:
parent
4cbec13690
commit
309b562eba
@ -1,150 +0,0 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
NONE = 0
|
||||
MSGID = 1
|
||||
MSGSTR = 2
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
all_total = {}
|
||||
all_untranslated = {}
|
||||
all_percent_s = {}
|
||||
all_named_s = {}
|
||||
all_bnamed_s = {}
|
||||
all_coverage = {}
|
||||
|
||||
|
||||
def strip_quotes(st):
|
||||
if len(st.strip()) > 2:
|
||||
return st.strip()[1:-1]
|
||||
else:
|
||||
return ""
|
||||
|
||||
args = sys.argv
|
||||
while len(args) > 1:
|
||||
args = args[1:]
|
||||
|
||||
f = open(args[0],"r")
|
||||
|
||||
mode = NONE
|
||||
|
||||
string_map = {}
|
||||
current_msgid = ""
|
||||
current_msgstr = ""
|
||||
|
||||
for line in f.readlines():
|
||||
data = line.split(None,1)
|
||||
if mode == NONE:
|
||||
if len(data) > 0 and data[0] == "msgid":
|
||||
mode = MSGID
|
||||
if len(data) > 1:
|
||||
current_msgid = strip_quotes(data[1])
|
||||
elif mode == MSGID:
|
||||
if data[0][0] == '"':
|
||||
current_msgid += strip_quotes(line)
|
||||
elif data[0] == "msgstr":
|
||||
mode = MSGSTR
|
||||
if len(data) > 1:
|
||||
current_msgstr = strip_quotes(data[1])
|
||||
elif mode == MSGSTR:
|
||||
if line == "" or line[0] == "#":
|
||||
mode = NONE
|
||||
string_map[current_msgid] = current_msgstr
|
||||
elif len(data) > 0 and data[0][0] == '"':
|
||||
current_msgstr += strip_quotes(line)
|
||||
|
||||
f.close()
|
||||
|
||||
named = re.compile('%\((\w+)\)\d*s')
|
||||
bnamed = re.compile('%\((\w+)\)\d*[^sd]')
|
||||
|
||||
total = len(string_map)
|
||||
untranslated = 0
|
||||
percent_s = 0
|
||||
percent_s_list = []
|
||||
named_s = 0
|
||||
named_s_list = []
|
||||
bnamed_s = 0
|
||||
bnamed_s_list = []
|
||||
|
||||
|
||||
for i in string_map.keys():
|
||||
if string_map[i] == "":
|
||||
untranslated += 1
|
||||
continue
|
||||
|
||||
cnt1 = i.count('%s')
|
||||
cnt2 = string_map[i].count('%s')
|
||||
if cnt1 != cnt2:
|
||||
percent_s += 1
|
||||
percent_s_list.append(i)
|
||||
|
||||
list1 = named.findall(i)
|
||||
list2 = named.findall(string_map[i])
|
||||
if len(list1) != len(list2):
|
||||
percent_s += 1
|
||||
percent_s_list.append(i)
|
||||
|
||||
list1.sort()
|
||||
list2.sort()
|
||||
if list1 != list2:
|
||||
named_s += 1
|
||||
named_s_list.append(i)
|
||||
|
||||
match = bnamed.match(string_map[i])
|
||||
if match:
|
||||
bnamed_s +=1
|
||||
bnamed_s_list.append(i)
|
||||
|
||||
coverage = (1.0 - (float(untranslated)/float(total))) * 100
|
||||
|
||||
print "File: %s" % args[0]
|
||||
print "Total: %d" % total
|
||||
all_total[args[0]] = total
|
||||
print "Untranslated: %d" % untranslated
|
||||
all_untranslated[args[0]] = untranslated
|
||||
print "%%s mismatches: %d" % percent_s
|
||||
all_percent_s[args[0]] = percent_s
|
||||
print "%%()s mismatches: %d" % named_s
|
||||
all_named_s[args[0]] = named_s
|
||||
print "%%() missing s/d: %d" % bnamed_s
|
||||
all_bnamed_s[args[0]] = bnamed_s
|
||||
print "Coverage: %5.2f%%" % coverage
|
||||
all_coverage[args[0]] = coverage
|
||||
|
||||
if percent_s:
|
||||
print "\n-------- %s mismatches --------------"
|
||||
for i in percent_s_list:
|
||||
print "'%s' : '%s'" % (i, string_map[i])
|
||||
|
||||
if named_s:
|
||||
print "\n-------- %()s mismatches ------------"
|
||||
for i in named_s_list:
|
||||
print "'%s' : '%s'" % (i, string_map[i])
|
||||
|
||||
if bnamed_s:
|
||||
print "\n-------- %() missing s or d ---------"
|
||||
for i in bnamed_s_list:
|
||||
print "'%s' : '%s'" % (i, string_map[i])
|
||||
print ""
|
||||
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
print "\n\nFile \tTotal \tUntranslated. \t%s mismatch \t%()s mismatch \tmissing s/d \tCoverage"
|
||||
for pofile in sys.argv[1:]:
|
||||
print "%s \t%5d \t%7d \t%7d \t%7d \t%7d \t%3.2f%%" %\
|
||||
(pofile,
|
||||
all_total[pofile],
|
||||
all_untranslated[pofile],
|
||||
all_percent_s[pofile],
|
||||
all_named_s[pofile],
|
||||
all_bnamed_s[pofile],
|
||||
all_coverage[pofile])
|
||||
|
||||
f = open("used_strings.txt","w")
|
||||
keys = string_map.keys()
|
||||
keys.sort()
|
||||
for i in keys:
|
||||
f.write(i + "\n")
|
||||
f.close()
|
14754
gramps2/po/cs.po
14754
gramps2/po/cs.po
File diff suppressed because it is too large
Load Diff
16785
gramps2/po/da.po
16785
gramps2/po/da.po
File diff suppressed because it is too large
Load Diff
15056
gramps2/po/de.po
15056
gramps2/po/de.po
File diff suppressed because it is too large
Load Diff
15385
gramps2/po/eo.po
15385
gramps2/po/eo.po
File diff suppressed because it is too large
Load Diff
14710
gramps2/po/es.po
14710
gramps2/po/es.po
File diff suppressed because it is too large
Load Diff
14591
gramps2/po/fi.po
14591
gramps2/po/fi.po
File diff suppressed because it is too large
Load Diff
14553
gramps2/po/fr.po
14553
gramps2/po/fr.po
File diff suppressed because it is too large
Load Diff
15136
gramps2/po/hu.po
15136
gramps2/po/hu.po
File diff suppressed because it is too large
Load Diff
15277
gramps2/po/it.po
15277
gramps2/po/it.po
File diff suppressed because it is too large
Load Diff
14971
gramps2/po/lt.po
14971
gramps2/po/lt.po
File diff suppressed because it is too large
Load Diff
14863
gramps2/po/nb.po
14863
gramps2/po/nb.po
File diff suppressed because it is too large
Load Diff
16254
gramps2/po/nl.po
16254
gramps2/po/nl.po
File diff suppressed because it is too large
Load Diff
14863
gramps2/po/no.po
14863
gramps2/po/no.po
File diff suppressed because it is too large
Load Diff
13011
gramps2/po/pl.po
13011
gramps2/po/pl.po
File diff suppressed because it is too large
Load Diff
14696
gramps2/po/pt_BR.po
14696
gramps2/po/pt_BR.po
File diff suppressed because it is too large
Load Diff
14387
gramps2/po/ro.po
14387
gramps2/po/ro.po
File diff suppressed because it is too large
Load Diff
16243
gramps2/po/ru.po
16243
gramps2/po/ru.po
File diff suppressed because it is too large
Load Diff
14452
gramps2/po/sk.po
14452
gramps2/po/sk.po
File diff suppressed because it is too large
Load Diff
14439
gramps2/po/sv.po
14439
gramps2/po/sv.po
File diff suppressed because it is too large
Load Diff
12504
gramps2/po/zh_CN.po
12504
gramps2/po/zh_CN.po
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user