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

Phil Thompson phil at river-bank.demon.co.uk
Sat Sep 1 18:01:48 BST 2001


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?

Phil




More information about the PyQt mailing list