[PyKDE] Feedback Needed on Possible tr() Changes

Phil Thompson phil at riverbankcomputing.co.uk
Mon May 26 15:51:01 BST 2003


On Monday 26 May 2003 8:20 am, Jan L. Nauta wrote:
> Or another alternative would be:
>
> 4. Your implementation of QObject::tr() now does a dynamic lookup of the
> class name. You could use the QTranslator::contains() method to check if a
> particular context/string is available in a translator, starting with the
> class. If the class doesn't have a translation, check with the base
> class(es)...
>
> <code>
> if python_translator installed :
>     class = class type of self
>     while class :
>         if python_translator.contains(class.name, string) :
>             return translated string
>         class = base class
>
> previous implementation
> </code>
>
> All you need now is a PyQt call to set the python_translator. If the
> python_translator isn't set, the 'old' implementation is used. This way no
> sources have to be changed, and the new behavious is only available if
> requested.

This still doesn't reproduce the C++ behaviour. If somebody ships a class 
library, implemented in Python and including translation files, then there is 
the possibility that an application translation will be used instead of the 
intended class library one.

Phil




More information about the PyQt mailing list