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

List:       kde-bindings
Subject:    Re: [Kde-bindings] Using i18n
From:       Shaheed Haque <srhaque () theiet ! org>
Date:       2013-05-03 22:25:01
Message-ID: CAHAc2jdsXe3+=A=ZMx70o8cvFWtBje+Jp9qP=WMnhwjE48W21Q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


[looping in Luca]

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


On 3 May 2013 22:40, Shaheed Haque <srhaque@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@theiet.org> wrote:
> 
> > I wonder if we can get PyKDE4 fixed?
> > 
> > 
> > On 3 May 2013 22:10, Shaheed Haque <srhaque@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@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@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@theiet.org> wrote:
> > > > > 
> > > > > > Hi Philipp,
> > > > > > 
> > > > > > On 3 May 2013 19:56, Philipp A. <flying-sheep@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/revis \
> > > > > > > ions/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@kde.org
> > > > > > > https://mail.kde.org/mailman/listinfo/kwrite-devel
> > > > > > > 
> > > > > > > 
> > > > > > 
> > > > > 
> > > > > _______________________________________________
> > > > > KWrite-Devel mailing list
> > > > > KWrite-Devel@kde.org
> > > > > https://mail.kde.org/mailman/listinfo/kwrite-devel
> > > > > 
> > > > > 
> > > > 
> > > > _______________________________________________
> > > > KWrite-Devel mailing list
> > > > KWrite-Devel@kde.org
> > > > https://mail.kde.org/mailman/listinfo/kwrite-devel
> > > > 
> > > > 
> > > 
> > 
> 


[Attachment #5 (text/html)]

<div dir="ltr">[looping in Luca]<div><br></div><div><a \
href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg26504.html">http://ww \
w.mail-archive.com/pyqt@riverbankcomputing.com/msg26504.html</a><br></div></div><div \
class="gmail_extra"> <br><br><div class="gmail_quote">On 3 May 2013 22:40, Shaheed \
Haque <span dir="ltr">&lt;<a href="mailto:srhaque@theiet.org" \
target="_blank">srhaque@theiet.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <div dir="ltr">Dear bindings team, is there a way to get \
this issue looked at?</div><div class="HOEnZb"><div class="h5"><div \
class="gmail_extra"><br><br><div class="gmail_quote">On 3 May 2013 22:34, Shaheed \
Haque <span dir="ltr">&lt;<a href="mailto:srhaque@theiet.org" \
target="_blank">srhaque@theiet.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">I wonder if we can get PyKDE4 \
fixed?</div><div><div><div class="gmail_extra"><br> <br><div class="gmail_quote">On 3 \
May 2013 22:10, Shaheed Haque <span dir="ltr">&lt;<a href="mailto:srhaque@theiet.org" \
target="_blank">srhaque@theiet.org</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">Gah, I see what you mean.<div><br></div><div>I \
guess I&#39;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...</div>



</div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On 3 May \
2013 21:17, Philipp A. <span dir="ltr">&lt;<a href="mailto:flying-sheep@web.de" \
target="_blank">flying-sheep@web.de</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <div dir="ltr"><div><div><div>well, it \
is:<br><br>&gt;&gt;&gt; from sys import version_info<br>&gt;&gt;&gt; \
version_info[:2]<br>(3, 3)<br>&gt;&gt;&gt; from PyKDE4.kdecore import versionString, \
i18n<br>&gt;&gt;&gt; versionString()<br>




&#39;4.10.2&#39;<br>&gt;&gt;&gt; i18n(&#39; \
·&#39;.encode(&#39;utf-8&#39;))<br></div>&#39; ·&#39;<br>&gt;&gt;&gt; \
print(i18n(&#39; ·&#39;))<br>Traceback (most recent call last):<br>   File \
&quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>




UnicodeEncodeError: &#39;ascii&#39; codec can&#39;t encode character &#39;\xb7&#39; \
in position 0: ordinal not in range(128)<br><br></div>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.<br>




<br></div>so i18n is buggy on KDE 4.10, and we have to work around \
it.<br></div><div><div><div class="gmail_extra"><br><br><div \
class="gmail_quote">2013/5/3 Shaheed Haque <span dir="ltr">&lt;<a \
href="mailto:srhaque@theiet.org" \
target="_blank">srhaque@theiet.org</a>&gt;</span><br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">Just after I hit &quot;send&quot;, I found \
this:<div><br></div><div><a \
href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14058.html" \
target="_blank">http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14058.html</a> \
</div>





<div><br></div><div>which suggests this is not an issue???</div></div><div><div><div \
class="gmail_extra"><br><br><div class="gmail_quote">On 3 May 2013 20:42, Shaheed \
Haque <span dir="ltr">&lt;<a href="mailto:srhaque@theiet.org" \
target="_blank">srhaque@theiet.org</a>&gt;</span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><div>Hi Philipp,<br></div><div \
class="gmail_extra"><br><div class="gmail_quote"><div>On 3 May 2013 19:56, Philipp A. \
<span dir="ltr">&lt;<a href="mailto:flying-sheep@web.de" \
target="_blank">flying-sheep@web.de</a>&gt;</span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div \
dir="ltr"><div><div><div><div>Hi, i've seen some uses of kdecore.i18n popping up in \
Paté plugins, and have some recommendations:<br>






<div><br></div>2. It takes more than one argument. so for the sake of consistency \
instead of doing the ugly<br>  i18n(b&#39;foo %(name)s.&#39;) % { &#39;name&#39;: \
&#39;bar&#39;}<br><div>or even the better<br></div><div>      i18n(b&#39;foo \
{name}.&#39;).format(name=&#39;bar&#39;)<br></div>we should do the Qt-style<br>       \
i18n(b&#39;foo %1.&#39;, &#39;bar&#39;)<br>







<br></div><div>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.<br></div></div></div>






</div></div></blockquote><div><br></div></div><div><div>I&#39;ve been using the \
argument syntax of the third form, but simply specified quoted strings (i.e. without \
the &quot;b&quot; 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&#39;d certainly prefer not avoid \
having to use &quot;b&quot; all over the place.</div>






<div><br></div><div><a \
href="https://github.com/Werkov/PyQt4/blob/master/examples/tools/i18n/i18n.py" \
target="_blank">https://github.com/Werkov/PyQt4/blob/master/examples/tools/i18n/i18n.py</a><br></div><div><br></div><div>






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?</div> </div><div><br></div><div>Thanks, Shaheed</div><div>  </div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">






<div>
<div dir="ltr"><div><div><div><div><br></div><div>we have to come up with a \
solution.<br> <br></div><div>there is a possible solution here, but it involves a \
fairly convoluted i18n replacement:<br><a \
href="https://projects.kde.org/projects/kde/applications/kate/repository/revisions/mas \
ter/entry/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py#L36" \
target="_blank">https://projects.kde.org/projects/kde/applications/kate/repository/rev \
isions/master/entry/addons/kate/pate/src/plugins/python_console_ipython/python_console_ipython.py#L36</a><br>








<br></div><div>should we add that function to libkatepate and call it a \
day?<br></div></div></div></div></div> \
<br></div>_______________________________________________<br> KWrite-Devel mailing \
list<br> <a href="mailto:KWrite-Devel@kde.org" \
target="_blank">KWrite-Devel@kde.org</a><br> <a \
href="https://mail.kde.org/mailman/listinfo/kwrite-devel" \
target="_blank">https://mail.kde.org/mailman/listinfo/kwrite-devel</a><br> \
<br></blockquote></div><br></div></div> </blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
KWrite-Devel mailing list<br>
<a href="mailto:KWrite-Devel@kde.org" target="_blank">KWrite-Devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kwrite-devel" \
target="_blank">https://mail.kde.org/mailman/listinfo/kwrite-devel</a><br> \
<br></blockquote></div><br></div> \
</div></div><br>_______________________________________________<br> KWrite-Devel \
mailing list<br> <a href="mailto:KWrite-Devel@kde.org" \
target="_blank">KWrite-Devel@kde.org</a><br> <a \
href="https://mail.kde.org/mailman/listinfo/kwrite-devel" \
target="_blank">https://mail.kde.org/mailman/listinfo/kwrite-devel</a><br> \
<br></blockquote></div><br></div> </div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>



_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings


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

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