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

Unified Diff: cms/sources.py

Issue 5242593268989952: Issue 2340 - Don`t generate pages if less than 30% have been translated (Closed)
Patch Set: Don`t link to pages that don`t exist Created May 6, 2015, 3:19 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
Index: cms/sources.py
===================================================================
--- a/cms/sources.py
+++ b/cms/sources.py
@@ -32,36 +32,29 @@ class Source:
if parsed.scheme != "" or page.startswith("/") or page.startswith("."):
# Not a page link
return None, None
if page == "" and url != "":
# Page-relative link
return None, None
- def has_locale(locale, page):
- try:
- page = config.get("locale_overrides", page)
Sebastian Noack 2015/05/06 16:15:30 So locale overrides are now only repsected when ge
Wladimir Palant 2015/05/06 17:21:59 No, this logic is actually built into the default
- except ConfigParser.Error:
- pass
- return self.has_locale(locale, page)
-
config = self.read_config()
default_locale = config.get("general", "defaultlocale")
default_page = config.get("general", "defaultpage")
alternative_page = "/".join([page, default_page]).lstrip("/")
if self.has_localizable_file(default_locale, page):
if not self.has_localizable_file(locale, page):
locale = default_locale
elif self.has_page(page):
- if not has_locale(locale, page):
+ if not self.has_locale(locale, page):
locale = default_locale
elif self.has_page(alternative_page):
- if not has_locale(locale, alternative_page):
+ if not self.has_locale(locale, alternative_page):
locale = default_locale
else:
logging.warning("Link to %s cannot be resolved", page)
parts = page.split("/")
if parts[-1] == default_page:
page = "/".join(parts[:-1])
@@ -152,18 +145,20 @@ class Source:
for filename in self.list_files("locales"):
if "/" in filename:
locale, path = filename.split("/", 1)
result.add(locale)
return result
def has_locale(self, locale, page):
config = self.read_config()
- if config.has_option("locale_overrides", page):
+ try:
page = config.get("locale_overrides", page)
+ except ConfigParser.Error:
+ pass
return self.has_file(self.locale_filename(locale, page))
def read_locale(self, locale, page):
default_locale = self.read_config().get("general", "defaultlocale")
if locale == default_locale:
result = {}
else:
result = dict(self.read_locale(default_locale, page))

Powered by Google App Engine
This is Rietveld