Ok, so after much digging I think I can stop some or all of the python
i18n madness (or at least this is a significant amount of information
about the madness).

 I've created a simple test program:

http://people.redhat.com/jantill/yum/i18n-tst.py

...this just outputs _some of_ rpm's i18n messages directly and then
from gettext. I've run it using the Fed-8 rpm, but given the messages in
question haven't changed I'm assuming the translations haven't for Fed-9
either (and all the BZs :).

 I just added all the msg id's that seemed to be obviously linked with
GPG key imports ... as that's one of the places we are failing
(according to 438580).

 So everything works by default in en_US.UTF-8, but in pl_PL.UTF-8 you
get:

"""
%s: was already signed by key ID %s, skipping

Traceback (most recent call last):
  File "/home/james/work/rpm/i18n-tst.py", line 53, in <module>
    out("%s: was already signed by key ID %s, skipping\n")
  File "/home/james/work/rpm/i18n-tst.py", line 49, in out
    sys.stdout.write(_(x))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u017c' in
position 6: ordinal not in range(128)
"""

...so I added parameters to the script to change behaviour a bit, and
it's interesting to see what makes it work again:

1. fail - ignore the problem messages, hand coded for pl_PL :)

2. print - This makes the script use "print" instead of
sys.stdout.write() ... although note that this _doesn't_work_ if we pipe
to cat and turn the tty magic off.

3. "| cat" - Using the default params. but piping the results to cat
makes it not fault ... as long as you don't pass tty to turn the magic
tty locale thing off.

3. gettext.unicode - The makes the script use t.gettext instead of
t.ugettext.

...the last one doesn't make much sense to me either, however it is
worth noting that currently i18n.py defines _() to return a non-unicode
string when a catalogue cannot be found (which is true for en_US).
 So the one line patch[1] would make translated messages have the same
type that non-translated ones do now ... and _seems_ to work (I'm asking
the reporters now, if it fixes it for them too).

 The other option is to work out what magic is missing in the stdout
case when going to a tty, and see if we can do that by hand.

 The last option being to just refile all the bugs against rpm :).


[1] The patch is:

diff --git a/yum/i18n.py b/yum/i18n.py
index f735edd..dcab01e 100644
--- a/yum/i18n.py
+++ b/yum/i18n.py
@@ -21,7 +21,7 @@ try:
     '''
     import gettext
     t = gettext.translation('yum')
-    _ =  t.ugettext
+    _ =  t.gettext
 except:
     '''
     Something went wrong so we make a dummy _() wrapper there is just

-- 
James Antill <[EMAIL PROTECTED]>
Red Hat

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to