[PyKDE] Phil: Any chance of getting the TR (translate) method
working?
Boudewijn Rempt
bsarempt at xs4all.nl
Wed Aug 1 07:32:22 BST 2001
I want to get a section on translating applications in
the last chapter on deploying applications, but I haven't
arrived there. I'll be testing this as soon as I do...
On Tue, 31 Jul 2001, Bryan Brunton wrote:
>
> (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/
>
> _______________________________________________
> PyKDE mailing list PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde
>
More information about the PyQt
mailing list