[PyQt] Translations failing when not using "self" for the instance

Thorsten Kampe thorsten at thorstenkampe.de
Fri Dec 3 11:36:44 GMT 2010


Hi,

when using other names for the self idiom referring to the current 
instance (like "inst" for example - see [1]), the application is not 
correctly translated.

If I open the generated ts file in Qt Linguist it shows two "contexts" 
("MainWindow" and "inst") instead of just one ("MainWindow) when using 
"self".

The translation for the text in the script ("inst.tr('Ready')" for 
example) shows still English - while the ones from the resource file 
work.

Is that a problem with pyuic or with pylupdate4?


Thorsten

[1]
from PyQt4 import QtGui, QtCore
import resource.ui

class MainWindow(QtGui.QMainWindow, resource.ui.Ui_MainWindow):
    def __init__(inst):
        QtGui.QMainWindow.__init__(inst)
        inst.setupUi(inst)
        inst.statusBar().showMessage(inst.tr('Ready'))



More information about the PyQt mailing list