use better varnames [PEP8 says varnames such as l are way bad for maintability and high readability, comment the code, cleanup so it does not hide logic. thanks Yann for explaining the logic

This commit is contained in:
Nikos Kouremenos 2006-02-21 11:12:54 +00:00
parent e85c373a95
commit faccf1e321

View file

@ -36,16 +36,20 @@ else:
# set '' so each part of the locale that should be modified is set # set '' so each part of the locale that should be modified is set
# according to the environment variables # according to the environment variables
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
# Add LANG to os.environ
l = os.environ.get('LANG') ## Add LANG to os.environ ##
if not l: # get LANG, fallback to ''; LANG can be 'en_US:el_GR.UTF-8:fr_FR'
l = '' lang = os.environ.get('LANG', '')
default_l = locale.getdefaultlocale()[0] default_loc = locale.getdefaultlocale()[0] # en_US, fr_FR, el_GR etc..
if not default_l in l.split(':'): if default_loc not in lang.split(':'): # is the default locale a value of LANG?
l += ':' + default_l # no, add it!
if l[0] == ':': #remove the forst : if lang == '':
l = l[1:] lang = default_loc
os.environ['LANG'] = l else:
lang += ':' + default_loc
os.environ['LANG'] = lang
_translation = None _translation = None
def init(): def init():