[PyQt] multiple languages within the same application
Samuele Carcagno
sam.carcagno at gmail.com
Mon Mar 14 21:32:28 GMT 2011
On Monday 14 March 2011 21:15:17 David Boddie wrote:
> On Mon Mar 14 17:34:19 GMT 2011, Samuele Carcagno wrote:
>
> > is it possible to have different parts of an application translated into
> > different languages? For example say that an application has two buttons,
> > would it be possible to have the label of button1 translated in Italian and
> > the label of button2 translated in French?
>
> Yes, it's possible.
>
> > If it is possible, how would I go about it? The
> > QApplication.installTranslator() function seems to affect the application
> > globally, and I don't see an easy way to select a particular translator for
> > a specific widget or group of widgets.
>
> You might find it interesting to look at the i18n example supplied with PyQt.
> It is located in the examples/tools/i18n directory.
Many thanks for the pointer, I think it will solve my problem, so what I can do to
have two strings translated in different languages is:
locale = "it_IT"
italianTranslator = QtCore.QTranslator()
italianTranslator.load("myapp_" + locale, ":/translations/")
locale = "fr_FR"
franchTranslator = QtCore.QTranslator()
frenchTranslator.load("myapp_" + locale, ":/translations/")
button1.setText(italianTranslator.translate("", "Label 1")
button2.setText(frenchTranslator.translate("", "Label 2")
Sam
>
> David
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
More information about the PyQt
mailing list