mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-27 03:37:33 +00:00
104 lines
3.4 KiB
Diff
104 lines
3.4 KiB
Diff
=== modified file 'Compiler/compiler.py'
|
|
--- Compiler/compiler.py 2006-10-20 19:05:18 +0000
|
|
+++ Compiler/compiler.py 2006-10-20 19:11:15 +0000
|
|
@@ -10,9 +10,10 @@
|
|
|
|
|
|
class UICompiler(uiparser.UIParser):
|
|
- def __init__(self):
|
|
+ def __init__(self, gettext):
|
|
uiparser.UIParser.__init__(self, qtproxies.QtCore, qtproxies.QtGui,
|
|
CompilerCreatorPolicy())
|
|
+ qtproxies.i18n_gettext = gettext
|
|
|
|
|
|
def reset(self):
|
|
|
|
=== modified file 'Compiler/qtproxies.py'
|
|
--- Compiler/qtproxies.py 2006-10-20 19:05:18 +0000
|
|
+++ Compiler/qtproxies.py 2006-10-20 19:29:54 +0000
|
|
@@ -7,6 +7,7 @@
|
|
|
|
i18n_strings = []
|
|
i18n_context = ""
|
|
+i18n_gettext = False
|
|
|
|
def i18n_print(string):
|
|
i18n_strings.append(string)
|
|
@@ -62,7 +63,10 @@
|
|
return re.sub(r"\n", r'\\n"\n"', x)
|
|
|
|
def __str__(self):
|
|
- return "QtGui.QApplication.translate(\"%s\", \"%s\", None, QtGui.QApplication.UnicodeUTF8)" % (i18n_context, self.escape(self.string))
|
|
+ if i18n_gettext:
|
|
+ return "_(u\"%s\")" % (self.escape(self.string))
|
|
+ else:
|
|
+ return "QtGui.QApplication.translate(\"%s\", \"%s\", None, QtGui.QApplication.UnicodeUTF8)" % (i18n_context, self.escape(self.string))
|
|
|
|
|
|
# classes with this flag will occur in retranslateUi completely
|
|
|
|
=== modified file '__init__.py'
|
|
--- __init__.py 2006-10-20 19:05:18 +0000
|
|
+++ __init__.py 2006-10-20 19:09:37 +0000
|
|
@@ -30,8 +30,8 @@
|
|
"""
|
|
|
|
|
|
-def compileUi(uifile, pyfile, execute=False, indent=4):
|
|
- """compileUi(uifile, pyfile, execute=False, indent=4)
|
|
+def compileUi(uifile, pyfile, execute=False, indent=4, gettext=False):
|
|
+ """compileUi(uifile, pyfile, execute=False, indent=4, gettext=False)
|
|
|
|
Creates a Python module from a Qt Designer .ui file.
|
|
|
|
@@ -51,7 +51,7 @@
|
|
|
|
pyfile.write(_header % (uifname, time.ctime(), PYQT_VERSION_STR))
|
|
|
|
- winfo = compiler.UICompiler().compileUi(uifile, pyfile)
|
|
+ winfo = compiler.UICompiler(gettext).compileUi(uifile, pyfile)
|
|
|
|
if execute:
|
|
indenter.write_code(_display_code % winfo)
|
|
|
|
=== modified file 'pyuic.py'
|
|
--- pyuic.py 2006-10-20 19:05:18 +0000
|
|
+++ pyuic.py 2006-10-20 19:08:40 +0000
|
|
@@ -19,13 +19,13 @@
|
|
return app.exec_()
|
|
|
|
|
|
-def generateUi(uifname, pyfname, execute, indent):
|
|
+def generateUi(uifname, pyfname, execute, indent, gettext):
|
|
if pyfname == "-":
|
|
pyfile = sys.stdout
|
|
else:
|
|
pyfile = file(pyfname, "w")
|
|
|
|
- uic.compileUi(uifname, pyfile, execute, indent)
|
|
+ uic.compileUi(uifname, pyfile, execute, indent, gettext)
|
|
return 0
|
|
|
|
|
|
@@ -46,6 +46,9 @@
|
|
optparser.add_option("-i", "--indent", dest="indent",
|
|
action="store", type="int", default=4, metavar="N",
|
|
help="set indent width to N spaces, tab if N is 0 (default: 4)")
|
|
+optparser.add_option("-g", "--gettext", dest="gettext",
|
|
+ action="store_true", default=False,
|
|
+ help="generate gettext-compatible translations calls")
|
|
|
|
options, args = optparser.parse_args(sys.argv)
|
|
|
|
@@ -62,7 +65,7 @@
|
|
if options.preview:
|
|
error = previewUi(args[1])
|
|
else:
|
|
- error = generateUi(args[1], options.output, options.execute, options.indent)
|
|
+ error = generateUi(args[1], options.output, options.execute, options.indent, options.gettext)
|
|
except IOError, e:
|
|
sys.stderr.write("Error: %s: \"%s\"\n" % (e.strerror, e.filename))
|
|
|
|
|