Add the possibility to specify a list of alternatives for locales. Fixes #115

This commit is contained in:
Alexis Metaireau 2011-05-19 17:28:45 +01:00
commit 5277b9dc16
2 changed files with 18 additions and 2 deletions

View file

@ -53,6 +53,19 @@ def read_settings(filename):
if key.isupper():
context[key] = tempdict[key]
# if locales is not a list, make it one
locales = context['LOCALE']
if type(locales) is str:
locales = [str]
# try to set the different locales, fallback on the default.
for locale_ in context['LOCALE']:
try:
locale.setlocale(locale.LC_ALL, locale_)
break # break if it is successfull
except locale.Error:
pass
# set the locale
locale.setlocale(locale.LC_ALL, context['LOCALE'])
return context