Closed baudm closed 9 years ago
Comment #1 originally posted by baudm on 2012-03-13T12:25:52.000Z:
this snippet shows exactly what happens if "STRING" is not Unicode string, but operated on that locale:
python -c 'import locale; locale.setlocale(locale.LC_ALL, "tr_TR.UTF-8"); print "STRING".lower()'
Comment #2 originally posted by baudm on 2012-03-13T13:19:26.000Z:
Hi, could you try commenting out the call to ufw_localize() in ufw-gtk and check if that changes anything?
Comment #3 originally posted by baudm on 2012-03-13T13:28:52.000Z:
Hah, it does (ufw 0.31.1 and 0.30.1):
Traceback (most recent call last):
File "/usr/sbin/ufw-gtk", line 9, in
Comment #4 originally posted by baudm on 2012-04-01T13:36:12.000Z:
Hello, it's been a while. Could you try applying the attached patch and test again? Thanks.
Comment #5 originally posted by baudm on 2012-04-01T15:26:02.000Z:
Hi! With this patch I also needed to add "import os" to l10n.py. I get the same error:
Missing policy for 'input'
Comment #6 originally posted by baudm on 2012-04-01T15:42:48.000Z:
Sorry about the missing import; I generated the patch too soon. Anyway, please test this new patch. I've removed the l10n stuff for ufw-frontends since it's not really needed right now.
Comment #7 originally posted by baudm on 2012-04-01T16:15:06.000Z:
Same thing happens.
Comment #8 originally posted by baudm on 2012-04-05T10:05:33.000Z:
Hmm, I'm stumped so I read about i18n in PyGTK's FAQ; hopefully, it helps. I can't reproduce this bug that's why I'm attaching 3 patches to possibly fix this.
Patch 3a sets the locale to the user's setting, binds a text domain to it, and uses both the gettext API and class-based API (similar to ufw).
Patch 3b is essentially the same as 3a except that it only uses the class-based API of the gettext module.
Patch 3c sets the locale to 'C' and uses the gettext class-based API (as per your suggestion).
Comment #9 originally posted by baudm on 2012-04-05T12:41:26.000Z:
Wow, nice! Patches "a" and "b" don't do the job, but it's OK with the "c" one.
Thanks for the good job.
PS This bug required some interaction. :) If at any point it'd be useful for you to contact with me directly via IRC, IM or mail, no problem.
Just tested, seems to work with 0.30.1 too.
Comment #10 originally posted by baudm on 2012-04-05T12:54:51.000Z:
Hmm, do those translations come from the ufw package itself? I'm actually confused because if you look at the ufw code, it uses both the gettext API and the class-based gettext API:
class-based API: gettext.install(ufw.common.programName)
gettext API: gettext.bindtextdomain(ufw.common.programName, \ os.path.join(ufw.common.transdir, 'messages')) gettext.textdomain(ufw.common.programName) = gettext.gettext
What's more confusing is that in the call to gettext.install(), the localedir was not specified (meaning the default localedir will be used). However, in the call to gettext.bindtextdomain(), a localedir was specified.
Anyway, I'll just commit patch 3c with your changes. Thanks a lot! :)
Comment #11 originally posted by baudm on 2012-04-05T16:28:37.000Z:
Fixed in commit af7b0fd01bca885d63b5c9b4ec320abcdb7881af
Comment #12 originally posted by baudm on 2012-04-05T19:09:14.000Z:
Hmm, do those translations come from the ufw package itself? In my case (Sabayon, Gentoo based, and the same is in Gentoo) they come from .po files shipped in ufw sources (using which .mo are generated). As far as I know, in Ubuntu ufw's translations are (also?) provided by language packs, but those aren't used on my system.
In ufw's build system installing of .mo is a bit borked (/usr/share/ufw/messages is not the best location :)). ref.: https://bugs.launchpad.net/ufw/+bug/626178
What's interesting is that if I do `strace ufw', I can see it doesn't even look for .mo files under /usr/share/ufw/messages despite the code you mention! On the other hand, ufw-gtk, after the last patch, looks into that directory. I have no idea why it works this way if set with gettext.install (your patch) but doesn't if set in gettext.bindtextdomain (ufw).
I'm actually confused because if you look at the ufw code, it uses both the gettext API and the class-based gettext API:
class-based API: gettext.install(ufw.common.programName)
gettext API: gettext.bindtextdomain(ufw.common.programName, \ os.path.join(ufw.common.transdir, 'messages')) gettext.textdomain(ufw.common.programName) = gettext.gettext
Maybe that's why they're lucky and the problem with Turkish locale doesn't occur with ufw itself? I don't know, it's just a guess. An interesting note, if I place "import locale; print locale.getlocale()" in ufw code, for example: --- backend.py +++ backend.py @@ -205,6 +205,7 @@
orig.close()
policies = ['accept', 'accept_no_track', 'drop', 'reject'] for c in [ 'input', 'output', 'forward' ]:
it prints "(None, None)" if I use "ufw status"; and if "ufw-gtk" executed, it used to print a string like "('pl_PL', 'UTF-8')". However your last patch changes that and "(None, None)" is now printed as well. :) (locale.setlocale(locale.LC_ALL, 'C') - precisely this line changes the behaviour.)
What's more confusing is that in the call to gettext.install(), the localedir was not specified (meaning the default localedir will be used). However, in the call to gettext.bindtextdomain(), a localedir was specified.
(see above)
The text field to type the comment is way too small, I needed to help it using geany :)
Original issue 19 created by baudm on 2012-03-13T12:23:53.000Z: