[PyQt] installTranslator does not work in help function
Martin Altmayer
martin.altmayer at web.de
Sun Jun 5 21:36:19 BST 2011
Hello,
it seems that whether the translation works depends on the context where
QApplication.installTranslator is called.
The following code works as it should:
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication([])
translator = QtCore.QTranslator()
translator.load("hello_de")
app.installTranslator(translator)
hello = QtGui.QPushButton(QtGui.QApplication.translate("Test","Hello
World!"))
hello.resize(100, 30)
hello.show()
app.exec_()
In contrast, the next application does not display the translated text,
although I simply moved the initialization into a function:
from PyQt4 import QtCore, QtGui
def init():
app = QtGui.QApplication([])
translator = QtCore.QTranslator()
translator.load("hello_de")
app.installTranslator(translator)
return app
app = init()
hello = QtGui.QPushButton(QtGui.QApplication.translate("Test","Hello
World!"))
hello.resize(100, 30)
hello.show()
app.exec_()
Did I make a mistake or is this a difference between PyQt and Qt? As far as
I understand, this is not covered by "Differences Between PyQt and Qt" (
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html) and
seems not to be documented elsewhere.
The appendix contains the ts-file that I used.
Thanks,
Martin Altmayer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110605/9609e065/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello_de.ts
Type: text/texmacs
Size: 298 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110605/9609e065/attachment.ts>
More information about the PyQt
mailing list