[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] How does sip.setapi("QString", 2) work with translations?
From:       Tobias Rzepka <tobias.rzepka () googlemail ! com>
Date:       2010-11-27 22:21:30
Message-ID: 4CF1846A.6000907 () googlemail ! com
[Download RAW message or body]

Hello Brett,

with sip.setapi("QString",2) you gets always an unicode string back, 
witch is a true python object. So there can't be any Qt methods any 
more. This is why your second example fails.
You have two solutions. The one you mentioned or since Python 2.6 the 
new unicode format method:

qApp.translate("test","Internationalize {0}").format(42)

or with named arguments:

qApp.translate("test","Internationalize {my_number}").format(my_number=42)

There are many other options for the format method described in the 
Python documentation.

Tobias

Brett Stottlemyer schrieb am 27.11.2010 21:27:
> Hi, all-
>
> I'd like to use  sip.setapi("QString",2), but I'm using internationalization
> as well and it is giving me some trouble.
>
> If I try:
>> qApp.translate("test","Internationalize")
> I get Unicode "Internationalize" as the result (as expected)
>
> When I try:
>> qApp.translate("test","Internationalize %1").arg("42")
> I get
> AttributeError: 'unicode' object has no attribute 'arg'.  I guess this is
> expected, too, but I was hoping Phil had done some magic to have it work as
> expected.
>
> Is there a way to get this to work using Qt style formatting?  Or do I need
> to convert everything to python-style, like this:
>> qApp.translate("test","Internationalize %d")%42
> Thanks,
> Brett
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic