mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add the possibility to specify a list of alternatives for locales. Fixes #115
This commit is contained in:
parent
34d29e6192
commit
5277b9dc16
2 changed files with 18 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue