Hello,<br><br>it seems that whether the translation works depends on the context where QApplication.installTranslator is called.<br>The following code works as it should:<br><br>from PyQt4 import QtCore, QtGui<br><br>app = QtGui.QApplication([])<br>
translator = QtCore.QTranslator()<br>translator.load("hello_de")<br>app.installTranslator(translator)<br><br>hello = QtGui.QPushButton(QtGui.QApplication.translate("Test","Hello World!"))<br>
hello.resize(100, 30)<br>hello.show()<br><br>app.exec_()<br><br><br>In contrast, the next application does not display the translated text, although I simply moved the initialization into a function:<br><br><br>from PyQt4 import QtCore, QtGui<br>
<br>def init():<br>  app = QtGui.QApplication([])<br>  translator = QtCore.QTranslator()<br>  translator.load("hello_de")<br>  app.installTranslator(translator)<br>  return app<br><br>app = init()<br><br>hello = QtGui.QPushButton(QtGui.QApplication.translate("Test","Hello World!"))<br>
hello.resize(100, 30)<br>hello.show()<br><br>app.exec_()<br><br><br>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" (<a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html">http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html</a>) and seems not to be documented elsewhere. <br>
<br>The appendix contains the ts-file that I used.<br><br>Thanks,<br>Martin Altmayer<br>