Index: cms/utils.py |
=================================================================== |
--- a/cms/utils.py |
+++ b/cms/utils.py |
@@ -17,17 +17,16 @@ |
from .converters import converters, TemplateConverter |
def process_page(source, locale, page, format, site_url_override=None): |
params = { |
"source": source, |
"template": "default", |
"locale": locale, |
- "title": "title", |
"page": page, |
"pagedata": source.read_page(page, format), |
"config": source.read_config(), |
} |
localefile = page |
if params["config"].has_option("locale_overrides", page): |
localefile = params["config"].get("locale_overrides", page) |
@@ -44,17 +43,23 @@ def process_page(source, locale, page, f |
except KeyError: |
raise Exception("Page %s uses unknown format %s" % (page, format)) |
# Note: The converter might change some parameters so we can only read in |
# template data here. |
params["templatedata"] = source.read_template(params["template"]) |
template_converter = TemplateConverter(params, key="templatedata") |
- params["available_locales"] = sorted( |
- filter( |
- lambda locale: source.has_locale(locale, localefile), |
- source.list_locales() |
- ) |
- ) |
+ defaultlocale = params["config"].get("general", "defaultlocale") |
+ params["defaultlocale"] = defaultlocale |
+ |
+ locales = [ |
+ locale |
+ for locale in source.list_locales() |
+ if source.has_locale(locale, localefile) |
+ ] |
+ if defaultlocale not in locales: |
+ locales.append(defaultlocale) |
+ locales.sort() |
+ params["available_locales"] = locales |
params["head"], params["body"] = converter() |
return template_converter() |