Head r728 and truth test

This commit is contained in:
Jon Tibble 2010-03-09 19:14:23 +00:00
commit 51d95b661c
4 changed files with 4685 additions and 829 deletions

View File

@ -40,7 +40,7 @@ class ScreenList(object):
self.current_display = 0 self.current_display = 0
def add_screen(self, screen): def add_screen(self, screen):
if screen[u'primary'] == True: if screen[u'primary']:
self.current = screen self.current = screen
self.screen_list.append(screen) self.screen_list.append(screen)
self.count += 1 self.count += 1
@ -70,4 +70,3 @@ class ScreenList(object):
# if scrn[u'number'] == screenNumber: # if scrn[u'number'] == screenNumber:
# self.screen = scrn # self.screen = scrn
# break # break

View File

@ -76,7 +76,7 @@ class AlertsManager(QtCore.QObject):
display text display text
""" """
log.debug(u'display alert called %s' % text) log.debug(u'display alert called %s' % text)
self.parent.maindisplay.parent.StatusBar.showMessage(self.trUtf8(u'')) self.parent.maindisplay.parent.StatusBar.showMessage(u'')
self.alertList.append(text) self.alertList.append(text)
if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded: if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded:
self.parent.maindisplay.parent.StatusBar.showMessage(\ self.parent.maindisplay.parent.StatusBar.showMessage(\

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@
############################################################################### ###############################################################################
import os import os
from cgi import escape
from ast import parse, NodeVisitor, Str from ast import parse, NodeVisitor, Str
ts_file = u"""<?xml version="1.0" encoding="utf-8"?> ts_file = u"""<?xml version="1.0" encoding="utf-8"?>
@ -45,7 +46,8 @@ ts_message = u""" <message>
class StringExtractor(NodeVisitor): class StringExtractor(NodeVisitor):
def __init__(self, strings, filename): def __init__(self, strings, filename, base_path):
self.base_path = base_path
self.filename = filename self.filename = filename
self.strings = strings self.strings = strings
self.classname = 'unknown' self.classname = 'unknown'
@ -58,10 +60,10 @@ class StringExtractor(NodeVisitor):
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
key = '%s-%s' % (self.classname, string) key = '%s-%s' % (self.classname, string)
self.strings[key] = [self.classname, self.filename, node.lineno, string] self.strings[key] = [self.classname, self.filename[len(self.base_path) + 1:], node.lineno, escape(string)]
self.generic_visit(node) self.generic_visit(node)
def parse_file(filename, strings): def parse_file(base_path, filename, strings):
file = open(filename, u'r') file = open(filename, u'r')
try: try:
ast = parse(file.read()) ast = parse(file.read())
@ -70,7 +72,7 @@ def parse_file(filename, strings):
return return
file.close() file.close()
StringExtractor(strings, filename).visit(ast) StringExtractor(strings, filename, base_path).visit(ast)
def write_file(filename, strings): def write_file(filename, strings):
translation_file = u'' translation_file = u''
@ -94,15 +96,18 @@ def write_file(filename, strings):
def main(): def main():
strings = {} strings = {}
start_dir = os.path.abspath(u'.') start_dir = os.path.abspath(u'..')
for root, dirs, files in os.walk(start_dir): for root, dirs, files in os.walk(start_dir):
for file in files: for file in files:
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), strings) parse_file(start_dir, os.path.join(root, file), strings)
print u'Generating TS file...', print u'Generating TS file...',
write_file(os.path.join(start_dir, u'i18n', u'openlp_en.ts'), strings) write_file(os.path.join(start_dir, u'resources', u'i18n', u'openlp_en.ts'), strings)
print u'done.' print u'done.'
if __name__ == u'__main__': if __name__ == u'__main__':
main() if os.path.split(os.path.abspath(u'.'))[1] != u'scripts':
print u'You need to run this script from the scripts directory.'
else:
main()