environment variable can contain only one language. Fixes #1606

This commit is contained in:
Yann Leboulanger 2006-02-22 12:36:56 +00:00
parent 042fb8e0df
commit 9991a13dcc
1 changed files with 7 additions and 11 deletions

View File

@ -37,17 +37,13 @@ else:
# according to the environment variables
locale.setlocale(locale.LC_ALL, '')
## Add, if needed, a value in LANG environmental variable ##
# get LANG, fallback to ''; LANG can be 'en_US:el_GR.UTF-8:fr_FR'
lang = os.environ.get('LANG', '')
default_loc = locale.getdefaultlocale()[0] # en_US, fr_FR, el_GR etc..
# is the default locale a value of LANG?
if default_loc and default_loc not in lang.split(':'):
# no, add it!
if lang == '':
lang = default_loc
else:
lang += ':' + default_loc
## Set, if needed, a value in LANG environmental variable ##
# get LANG, fallback to ''
lang = os.environ.get('LANG')
if not lang:
default_lang = locale.getdefaultlocale()[0] # en_US, fr_FR, el_GR etc..
if default_lang:
lang = default_lang
if lang:
os.environ['LANG'] = lang