From 9991a13dcc163144dfc750afcce079583c2c2338 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 22 Feb 2006 12:36:56 +0000 Subject: [PATCH] environment variable can contain only one language. Fixes #1606 --- src/common/i18n.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/common/i18n.py b/src/common/i18n.py index 16a452a57..29c99bf8e 100644 --- a/src/common/i18n.py +++ b/src/common/i18n.py @@ -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