From bbd6c2ed78f35f88c33ccf8e0b1754a11f7262b0 Mon Sep 17 00:00:00 2001 From: Michael Gorven Date: Fri, 27 Nov 2009 13:06:39 +0200 Subject: [PATCH] Count number of strings found. --- openlp-get-strings.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp-get-strings.py b/openlp-get-strings.py index e9dd26539..032fbd02f 100755 --- a/openlp-get-strings.py +++ b/openlp-get-strings.py @@ -43,11 +43,11 @@ ts_message = u""" """ strings = {} +count = 0 class StringExtractor(NodeVisitor): def __init__(self, strings, filename): - self.strings = strings self.filename = filename self.classname = 'unknown' @@ -56,8 +56,10 @@ class StringExtractor(NodeVisitor): self.generic_visit(node) def visit_Call(self, node): + global count if hasattr(node.func, 'attr') and node.func.attr == 'trUtf8' and isinstance(node.args[0], Str): string = node.args[0].s + count += 1 key = '%s-%s' % (self.classname, string) strings[key] = [self.classname, self.filename, node.lineno, string] self.generic_visit(node) @@ -100,6 +102,7 @@ def main(): if file.endswith(u'.py'): print u'Parsing "%s"' % file parse_file(os.path.join(root, file)) + print u'Found %s strings' % count print u'Generating TS file...', write_file(os.path.join(start_dir, u'i18n', u'openlp_en.ts')) print u'done.'