[PyQt] Translation of strings with Python formating
Detlev Offenbach
detlev at die-offenbachs.de
Tue Jan 4 09:33:28 GMT 2011
On Montag, 3. Januar 2011, Nahuel Defossé wrote:
> Hi
>
> I've noticed that both QObject.trUtf8 and QObject.tr do not return
> Python strings, what is rather unconvinient when using the % operator
> to format strings.
> I prefer str % operator since it accepts keyword arguments, something
> that is not that simple QString.arg method.
>
> What is your advice to get unicode or str from QObject.tr?
The obvious for Python2 would be
unicode(QObject.trUtf8("some Python string with %s")) % "placeholder"
For Python3 (using the QString API v2) you already get strings back.
> I tried to
> implement QApplication.translate, QApplication.tr and
> QApplication.trUtf8 with no
> results whether I used the staticmethod decorator or not.
>
> Thanks
> Nahuel
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the PyQt
mailing list