[PyKDE] Another translation question

Andreas Pakulat apaku at gmx.de
Thu Jun 29 23:49:15 BST 2006


On 30.06.06 00:24:10, Andreas Pakulat wrote:
> just had a look at generated code from pyuic4 and I'm curious:
> 
> Shouldn't pyuic4 use
> QtCore.QCoreApplication.translate(classname.objectName(), <somestring>)
> in retranslateUi(self, classname)?

Turns out it already does by redefining self.tr, however it's not
completely right, because it uses self.uiname, which is the objectName
of the class created.

The attached classes uses self.toplevelWidget.uiclass for the context
parameter. This makes translation of generated python code working and
by this "workaround" you can translate ui-forms.

Andreas

-- 
Never reveal your best argument.
-------------- next part --------------
--- PyQt-x11-gpl-4.0/pyuic/uic/Compiler/compiler.py	2006-06-10 14:43:21.000000000 +0200
+++ PyQt-x11-gpl-4.0.fixpyuic4/pyuic/uic/Compiler/compiler.py	2006-06-30 00:46:11.000000000 +0200
@@ -54,7 +54,7 @@
 \treturn QtGui.QApplication.translate("%s", string, None, QtGui.QApplication.UnicodeUTF8)
 
 def retranslateUi(self, %s):
-""" % (self.translator.split(".")[-1], self.uiname, self.uiname))
+""" % (self.translator.split(".")[-1], self.toplevelWidget.uiclass, self.uiname))
         indenter.indent()
         indenter.write("\n".join(qtproxies.i18n_strings))
         indenter.dedent()


More information about the PyQt mailing list