[PyKDE] Phil: Any chance of getting the TR (translate) method
working?
Boudewijn Rempt
boud at rempt.xs4all.nl
Sat Sep 1 19:26:17 BST 2001
On Sat, 1 Sep 2001, Phil Thompson wrote:
> Boudewijn Rempt wrote:
> >
> > On Fri, 31 Aug 2001, Phil Thompson wrote:
> > >
> > > Hmm, I tested 2.5 with the test case that Bryan provided and it seemed
> > > to work Ok. Do you have a test case that demonstrates the problem?
> > >
> >
> > I used exactly the same testcase - but did you remove the app.translate
> > line? That one was meant just to show that the translate() function
> > worked, but the tr not:
> >
> > 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()
> > # comment this one out to actually test the problem
> > #w.setCaption(a.translate("MyWidget", "Internationalization Example"))
> > a.setMainWidget(w)
> > w.show()
> > a.exec_loop()
>
> If I leave it commented out, then the caption is in English.
>
> If I comment it in, then the caption is in French.
>
> The output of the two print statements are "1" and "POSIX".
>
> Isn't that what is supposed to happen? What happens for you?
>
>
What's supposed to happen is that the caption is in French because
of the self.setCaption( self.tr("Internationalization Example" ) );
statement in the widget.
Boudewijn Rempt | http://www.valdyas.org
More information about the PyQt
mailing list