Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/utils.py

Issue 5694103719247872: Issue 2133 - Allow to specify default translation inline in pages rather than in a separate file (Closed)
Patch Set: Addressed comments Created March 12, 2015, 8:56 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cms/sources.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « cms/sources.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld