or., 2010.eko marren 26a 10:23(e)an, Aymeric Mansoux(e)k idatzi zuen:
altern said :

set locale this can be done from python

import locale
locale.setlocale(locale.LC_ALL, 'de_DE')

I just quickly browsed through the Python doc for this module, and it
seems to me that this just to be used by an application to change which
locale it should used
  - C if not set
  - system default if called with locale.setlocale(locale.LC_ALL,'')
  - custom if called with locale.setlocale(locale.LC_ALL,'blabla')

So unless I miss the point, or read too fast, this is not setting the
system default locale, which is what we want here :)

Meaning we probably have to set and store $LANG for the users that will
run this tool.

yes i realised earlier today about this. So we will need to mix
shell commands with python commands when we find they help. I think
in the case of getting the installed locales it does, does it?

import os
os.listdir('/usr/lib/locale')

['en_GB.utf8', 'de_DE.utf8', 'es_ES.utf8', 'eu_ES.utf8',
'ru_RU.utf8', 'locale-archive', 'fr_FR.utf8', 'en_US.utf8']

but the python output is different than the shell command output,
python only reads the .utf8 items

% locale -a
C
de_DE.iso885915
de_DE.utf8
en_GB.utf8
en_US.utf8
es_ES.iso885915
es_ES.utf8
eu_ES.iso885915
eu_ES.utf8
eu_FR.iso885915
fr_FR.iso885915
fr_FR.utf8
it_IT.iso885915
POSIX
pt_BR.iso885915
ru_RU.koi8r
ru_RU.utf8
sl_SI.iso885915

i dont know very well, as you probably noticed, all this locale
stuff so if i say something stupid just tell me ;) i will try not
to...

This is correct :)
I'm also puzzled by this difference.
On my system both methods works correctly

['fr_FR.utf8', 'fr_CH.utf8', 'fr_LU.utf8', 'fr_CA.utf8', 'fr_BE.utf8',
'en_US.utf8']

locale -a

C
en_US.utf8
fr_BE.utf8
fr_CA.utf8
fr_CH.utf8
fr_FR.utf8
fr_LU.utf8
POSIX

We can ignore C and POSIX in the selector.

better use the python one because it returns a python list. we should try to do as much as possible with pyton but it will be mostly stuff like this related to files, folders, permission and so on. the rest should be done with shell commands

Not sure why your results are not different..
try to sudo dpkg-reconfigure locales ?

not that i remember. maybe because i installed the system in basque it did something weird? otherwise you know i am specialist in screwing linux systems :)

---
[email protected]
http://identi.ca/group/puredyne
irc://irc.goto10.org/puredyne

Reply via email to