[Kde-bindings] Using i18n

Shaheed Haque srhaque at theiet.org
Fri May 3 22:25:01 UTC 2013


[looping in Luca]

http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg26504.html


On 3 May 2013 22:40, Shaheed Haque <srhaque at theiet.org> wrote:

> Dear bindings team, is there a way to get this issue looked at?
>
>
> On 3 May 2013 22:34, Shaheed Haque <srhaque at theiet.org> wrote:
>
>> I wonder if we can get PyKDE4 fixed?
>>
>>
>> On 3 May 2013 22:10, Shaheed Haque <srhaque at theiet.org> wrote:
>>
>>> Gah, I see what you mean.
>>>
>>> I guess I'd vote for any solution that minimised the amount of source
>>> changes needed if/when i18n is fixed, so I like your idea of sticking in
>>> the library. I guess anybody with an objection needs to speak up...
>>>
>>>
>>> On 3 May 2013 21:17, Philipp A. <flying-sheep at web.de> wrote:
>>>
>>>> well, it is:
>>>>
>>>> >>> from sys import version_info
>>>> >>> version_info[:2]
>>>> (3, 3)
>>>> >>> from PyKDE4.kdecore import versionString, i18n
>>>> >>> versionString()
>>>> '4.10.2'
>>>> >>> i18n('·'.encode('utf-8'))
>>>> '·'
>>>> >>> print(i18n('·'))
>>>> Traceback (most recent call last):
>>>>   File "<stdin>", line 1, in <module>
>>>> UnicodeEncodeError: 'ascii' codec can't encode character '\xb7' in
>>>> position 0: ordinal not in range(128)
>>>>
>>>> note that the result of i18n *is* a unicode string, and i18n *accepts*
>>>> unicode strings, but only if those unicode strings happen to only contain
>>>> ascii – just like in the bad old python2 times.
>>>>
>>>> so i18n is buggy on KDE 4.10, and we have to work around it.
>>>>
>>>>
>>>> 2013/5/3 Shaheed Haque <srhaque at theiet.org>
>>>>
>>>>> Just after I hit "send", I found this:
>>>>>
>>>>> http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14058.html
>>>>>
>>>>> which suggests this is not an issue???
>>>>>
>>>>>
>>>>> On 3 May 2013 20:42, Shaheed Haque <srhaque at theiet.org> wrote:
>>>>>
>>>>>> Hi Philipp,
>>>>>>
>>>>>> On 3 May 2013 19:56, Philipp A. <flying-sheep at web.de> wrote:
>>>>>>
>>>>>>> Hi, i’ve seen some uses of kdecore.i18n popping up in Paté plugins,
>>>>>>> and have some recommendations:
>>>>>>>
>>>>>>> 2. It takes more than one argument. so for the sake of consistency
>>>>>>> instead of doing the ugly
>>>>>>>     i18n(b'foo %(name)s.') % { 'name': 'bar'}
>>>>>>> or even the better
>>>>>>>     i18n(b'foo {name}.').format(name='bar')
>>>>>>> we should do the Qt-style
>>>>>>>     i18n(b'foo %1.', 'bar')
>>>>>>>
>>>>>>> 1.  i18n takes byte strings. even on python3. this means that every
>>>>>>> time a developer accustomed to python2 who doesn’t know it tries to use it,
>>>>>>> the plugin WILL break for python3 users.
>>>>>>>
>>>>>>
>>>>>> I've been using the argument syntax of the third form, but simply
>>>>>> specified quoted strings (i.e. without the "b" prefix). Without really
>>>>>> thinking about it, I had assumed that i18n would have done something
>>>>>> plausible on Python2 (not sure exactly what though!), and on Python3 it
>>>>>> would just be Unicode all the way. I'd certainly prefer not avoid having to
>>>>>> use "b" all over the place.
>>>>>>
>>>>>>
>>>>>> https://github.com/Werkov/PyQt4/blob/master/examples/tools/i18n/i18n.py
>>>>>>
>>>>>> seems to suggest that something like that is possible, but when I
>>>>>> went looking for some docs on this, but could not see an obvious spec. Do
>>>>>> you have a reference handy?
>>>>>>
>>>>>> Thanks, Shaheed
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> we have to come up with a solution.
>>>>>>>
>>>>>>> there is a possible solution here, but it involves a fairly
>>>>>>> convoluted i18n replacement:
>>>>>>>
>>>>>>> https://projects.kde.org/projects/kde/applications/kate/repository/revisions/master/entry/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py#L36
>>>>>>>
>>>>>>> should we add that function to libkatepate and call it a day?
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> KWrite-Devel mailing list
>>>>>>> KWrite-Devel at kde.org
>>>>>>> https://mail.kde.org/mailman/listinfo/kwrite-devel
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> KWrite-Devel mailing list
>>>>> KWrite-Devel at kde.org
>>>>> https://mail.kde.org/mailman/listinfo/kwrite-devel
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> KWrite-Devel mailing list
>>>> KWrite-Devel at kde.org
>>>> https://mail.kde.org/mailman/listinfo/kwrite-devel
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20130503/716213b3/attachment-0001.html>


More information about the Kde-bindings mailing list