forked from openlp/openlp
Count number of strings found.
This commit is contained in:
parent
30a3897d3d
commit
bbd6c2ed78
@ -43,11 +43,11 @@ ts_message = u""" <message>
|
|||||||
</message>
|
</message>
|
||||||
"""
|
"""
|
||||||
strings = {}
|
strings = {}
|
||||||
|
count = 0
|
||||||
|
|
||||||
class StringExtractor(NodeVisitor):
|
class StringExtractor(NodeVisitor):
|
||||||
|
|
||||||
def __init__(self, strings, filename):
|
def __init__(self, strings, filename):
|
||||||
self.strings = strings
|
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.classname = 'unknown'
|
self.classname = 'unknown'
|
||||||
|
|
||||||
@ -56,8 +56,10 @@ class StringExtractor(NodeVisitor):
|
|||||||
self.generic_visit(node)
|
self.generic_visit(node)
|
||||||
|
|
||||||
def visit_Call(self, node):
|
def visit_Call(self, node):
|
||||||
|
global count
|
||||||
if hasattr(node.func, 'attr') and node.func.attr == 'trUtf8' and isinstance(node.args[0], Str):
|
if hasattr(node.func, 'attr') and node.func.attr == 'trUtf8' and isinstance(node.args[0], Str):
|
||||||
string = node.args[0].s
|
string = node.args[0].s
|
||||||
|
count += 1
|
||||||
key = '%s-%s' % (self.classname, string)
|
key = '%s-%s' % (self.classname, string)
|
||||||
strings[key] = [self.classname, self.filename, node.lineno, string]
|
strings[key] = [self.classname, self.filename, node.lineno, string]
|
||||||
self.generic_visit(node)
|
self.generic_visit(node)
|
||||||
@ -100,6 +102,7 @@ def main():
|
|||||||
if file.endswith(u'.py'):
|
if file.endswith(u'.py'):
|
||||||
print u'Parsing "%s"' % file
|
print u'Parsing "%s"' % file
|
||||||
parse_file(os.path.join(root, file))
|
parse_file(os.path.join(root, file))
|
||||||
|
print u'Found %s strings' % count
|
||||||
print u'Generating TS file...',
|
print u'Generating TS file...',
|
||||||
write_file(os.path.join(start_dir, u'i18n', u'openlp_en.ts'))
|
write_file(os.path.join(start_dir, u'i18n', u'openlp_en.ts'))
|
||||||
print u'done.'
|
print u'done.'
|
||||||
|
Loading…
Reference in New Issue
Block a user