Bug#507774: [Python-apps-team] Bug#507774: phatch uses LC_CTYPE instead of LANG

2008-12-09 Thread Emmanuel Hainry
Citando Stani :
 Dear Emmanuel Hainry,
 Could you test the upstream trunk to double check if this bug is really
 fixed.
 

Yes, it works as expected with the bzr revision 545

Thanks for your work,

Emmanuel



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#507774: [Python-apps-team] Bug#507774: phatch uses LC_CTYPE instead of LANG

2008-12-07 Thread Stani
Hi Emilio,

Thanks a lot for your patch! I committed it to the upstream bzr trunk:
$ bzr commit -m fix for i18n by Pochu
Committing to: /home/stani/sync/python/phatch/trunk/
modified phatch/core/config.py
Committed revision 545.

This bug was also reported upstream:
https://bugs.launchpad.net/phatch/+bug/304132/+distrotask

I don't know how to link these two bug reports. (In launchpad I can only
figure out how to say also affects Debian, but I don't know what to use
for the url of the debian bug tracker.) So Emilio, if you know how to do
that, please do.

Dear Emmanuel Hainry,
Could you test the upstream trunk to double check if this bug is really
fixed.

Thanks,
Stani




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#507774: [Python-apps-team] Bug#507774: phatch uses LC_CTYPE instead of LANG

2008-12-05 Thread Emilio Pozuelo Monfort
[Stani, I've attached a patch for this bug, below I explain why I think it's 
right]

Emmanuel Hainry wrote:
 Package: phatch
 Version: 0.1.6-1
 Severity: normal
 
 
 Although I set my locales to speak in english but use french
 conventions:
 Locale: LANG=en_GB.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
 phatch speaks in french. Launching it as
 LC_CTYPE=en_GB.UTF-8 phatch 
 makes it speak in the right language however.

Phatch sets the locale at core/config.py, load_locale function, which uses the
locale python module:

locale.setlocale(locale.LC_ALL, '')
#get default canonical if necessary
if canonical == 'default':
canonical  = locale.getdefaultlocale()[0]#canonical


From the locale module help:
getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'))
Tries to determine the default locale settings and returns
them as tuple (language code, encoding).

According to POSIX, a program which has not called
setlocale(LC_ALL, ) runs using the portable 'C' locale.
Calling setlocale(LC_ALL, ) lets it use the default locale as
defined by the LANG variable. Since we don't want to interfere
with the current locale setting we thus emulate the behavior
in the way described above.

To maintain compatibility with other platforms, not only the
LANG variable is tested, but a list of variables given as
envvars parameter. The first found to be defined will be
used. envvars defaults to the search path used in GNU gettext;
it must always contain the variable name 'LANG'.

Except for the code 'C', the language code corresponds to RFC
1766.  code and encoding can be None in case the values cannot
be determined.


So it's looking if LC_ALL is set, if not, it looks for LC_CTYPE, then LANG, and
finally LANGUAGE. And as you have LC_CTYPE defined, it will choose that before
the LANG variable.

By looking at those env vars definitions at [1], I think Phatch should discard
LC_CTYPE and use LC_ALL and LANG instead (in that order).

Attached is a patch against trunk that fixes this.

Cheers,
Emilio

[1] 
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08_02
=== modified file 'phatch/core/config.py'
--- phatch/core/config.py	2008-04-05 21:40:10 +
+++ phatch/core/config.py	2008-12-05 10:15:40 +
@@ -68,7 +68,7 @@
 locale.setlocale(locale.LC_ALL, '')
 #get default canonical if necessary
 if canonical == 'default':
-canonical  = locale.getdefaultlocale()[0]#canonical
+canonical  = locale.getdefaultlocale(envvars=('LC_ALL', 'LANG'))[0] #canonical
 if canonical is None:
 #for mac
 canonical   = 'en'



signature.asc
Description: OpenPGP digital signature