[PyKDE] Phil: Any chance of getting the TR (translate) method working?

Bryan Brunton bryanbrun at yahoo.com
Wed Aug 1 00:49:18 BST 2001


(Reposting due to no response from previous post)

Does anyone have the QObject.tr() method working?  

You can use the .qm file from the QT 2.3.1 i8ln example to test the code down below.  The
QApplication.translate method will correctly translate.  The tr method of the MyWidget object will
not.

Could someone test this?


import sys
from qt import *

class MyWidget(QMainWindow):
     def __init__(self):
          QMainWindow.__init__(self,None,'',Qt.WDestructiveClose)
          self.setCaption( self.tr("Internationalization Example" ) );

if __name__ == '__main__':
                a = QApplication(sys.argv)
                QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()'))
                translator = QTranslator(None)
                translator.load( "mywidget_fr.qm", "." )
                a.installTranslator( translator )

                print(translator.contains("MyWidget", "Internationalization Example"))
                print(QTextCodec.locale())
                w = MyWidget()
                w.setCaption(a.translate("MyWidget", "Internationalization Example"))
                a.setMainWidget(w)
                w.show()
                a.exec_loop()



__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/




More information about the PyQt mailing list