Index: cms/utils.py |
=================================================================== |
--- a/cms/utils.py |
+++ b/cms/utils.py |
@@ -54,25 +54,35 @@ def get_page_params(source, locale, page |
# Note: The converter might change some parameters so we can only read in |
# template data here. |
params["templatedata"] = source.read_template(params["template"]) |
defaultlocale = params["config"].get("general", "defaultlocale") |
params["defaultlocale"] = defaultlocale |
locales = [ |
- locale |
- for locale in source.list_locales() |
+ l |
+ for l 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() |
+ if converter.total_translations > 0: |
+ params["translation_ratio"] = (1 - |
+ float(converter.missing_translations) / converter.total_translations) |
+ else: |
+ params["translation_ratio"] = 1 |
+ |
return params |
-def process_page(source, locale, page, format, site_url_override=None): |
+def process_page(source, locale, page, format, site_url_override=None, min_translated=0): |
+ params = get_page_params(source, locale, page, format, site_url_override) |
+ if params["translation_ratio"] < min_translated: |
+ return None |
+ |
return TemplateConverter( |
- get_page_params(source, locale, page, format, site_url_override), |
+ params, |
key="templatedata" |
)() |