forked from github/pelican
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
|
|
@ -39,7 +39,10 @@ Setting name (default value) what does it do?
|
|||
`JINJA_EXTENSIONS` (``[]``) A list of any Jinja2 extensions you want to use.
|
||||
`DELETE_OUTPUT_DIRECTORY` (``False``) Delete the output directory and just
|
||||
the generated files.
|
||||
`LOCALE` (''[1]_) Change the locale.
|
||||
`LOCALE` (''[1]_) Change the locale. A list of locales can be provided
|
||||
here or a single string representing one locale.
|
||||
When providing a list, all the locales will be tried
|
||||
until one works.
|
||||
`MARKUP` (``('rst', 'md')``) A list of available markup languages you want
|
||||
to use. For the moment, only available values
|
||||
are `rst` and `md`.
|
||||
|
|
|
|||
|
|
@ -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