[PyQt] i18n

Giovanni Bajo rasky at develer.com
Wed Feb 11 17:39:00 GMT 2009


On 2/11/2009 6:24 PM, David Boddie wrote:
> On Wed Feb 11 14:57:59 GMT 2009, Frédéric wrote:
> 
>> Does anybody could point me on example how to use i18n in PyQt?
> 
> Here's an example of an application that uses i18n:
> 
>   http://qt-apps.org/content/show.php/PyPI+Browser?content=52389
> 
> It's not necessarily a good example. ;-)
> 
>> Riverbank documentation says that one should not use tr() method, but
>> insteead QtCore.QCoreApplication.translate(). As the object must be
>> passed to this method, this not improves the readability :o/
> 
> To avoid problems, I have previously defined a helper method in subclasses
> where I thought it was necessary, like this:
> 
> class ActionEditorWidget(QLabel):
> 
>     def tr(self, text):
>         return qApp.translate("ActionEditorWidget", text)
> 

I don't see what this code is supposed to help.

The problem at hand occurs when you use self.tr() in a class that you 
later inherit. I don't see how redefining tr() in the base class is 
going to help.
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com




More information about the PyQt mailing list