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

Unified Diff: cms/sources.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/converters.py ('k') | cms/utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/sources.py
===================================================================
--- a/cms/sources.py
+++ b/cms/sources.py
@@ -37,17 +37,17 @@ class Source:
checked_page = page
if config.has_option("locale_overrides", page):
checked_page = config.get("locale_overrides", page)
if self.has_localizable_file(default_locale, checked_page):
if not self.has_localizable_file(locale, checked_page):
locale = default_locale
- elif self.has_locale(default_locale, checked_page):
+ elif self.has_page(checked_page):
if not self.has_locale(locale, checked_page):
locale = default_locale
else:
print >>sys.stderr, "Warning: Link to %s cannot be resolved" % page
if page == default_page:
page = ""
@@ -69,18 +69,25 @@ class Source:
return "pages/%s.%s" % (page, format)
def list_pages(self):
for filename in self.list_files("pages"):
root, ext = os.path.splitext(filename)
format = ext[1:].lower()
yield root, format
- def has_page(self, page, format):
- return self.has_file(self.page_filename(page, format))
+ def has_page(self, page, format=None):
+ if format is None:
+ from .converters import converters
+ return any(
+ self.has_page(page, format)
+ for format in converters.iterkeys()
+ )
+ else:
+ return self.has_file(self.page_filename(page, format))
def read_page(self, page, format):
return self.read_file(self.page_filename(page, format))
#
# Localizable files helpers
#
« no previous file with comments | « cms/converters.py ('k') | cms/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld