[PyKDE] PyQt Internationalization?

Dave Smith dts at one.net
Sat May 19 20:10:08 BST 2001


Hello all,

I'm trying to determine the best approach to supporting
internationalization
in a PyQt application, and to what extent PyQt supports
internationalization,
unicode, etc...  Has anyone here had any success / experience that they
can share?

So far I have been looking at the QTranslator class but have not managed

a working example yet.

I wrote the following sample PyQt app based off of the Qt linguist
tutorial
tt1.cpp but it does not work.  Any ideas what could be wrong?  I am
testing
on solaris, hpux, linux, and nt w/ python2.0, qt2.3.0, sip2.4 and
PyQt2.4.
The orig C++ tt1.cpp does work.

# BEGIN tt1.py:
import sys
from qt import *

def main ( ):
   appTopLevel = QApplication ( sys.argv )

   appTranslator = QTranslator ( None )

   # After creating a "tt1_la.qm" file (using the C++ code and Qt
linguist) the next
   # line does not appear to do anything.
   #appTranslator.load ( "tt1_la", "." )

   # I though this was my best bet but it doesn't seem to work either...

   appTranslator.insert ( 'QPushButton', 'Hello world!', 'Orbis, te
saluto!' )

   # The QTranslatorMessage class has not yet been implemented in PyQt.
   #appTranslator.insert ( QTranslatorMessage ( 'QPushButton', 'Hello
world!',
   #   None, 'Orbis, te saluto!' ) )

   appTopLevel.installTranslator ( appTranslator )

   hello = QPushButton ( QPushButton.tr('Hello world!'), None );

   appTopLevel.setMainWidget ( hello )
   hello.show ( )
   appTopLevel.exec_loop ( )

if __name__ == '__main__': main ( )
# END tt1.py

Also, any plans for a PyQt version of the Qt linguist tools?

Best regards,

Dave






More information about the PyQt mailing list