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

Unified Diff: cms/sources.py

Issue 29659605: Issue 6231 - Add tests for translation string substitution (Closed)
Patch Set: Add tests for partial translation and for get_string Created Jan. 19, 2018, 3:26 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 | « no previous file | tests/expected_output/de/translate » ('j') | tests/test_page_outputs.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/sources.py
===================================================================
--- a/cms/sources.py
+++ b/cms/sources.py
@@ -142,34 +142,33 @@
def read_static(self, filename):
return self.read_file(self.static_filename(filename), binary=True)[0]
#
# Locale helpers
#
- @classmethod
- def locale_filename(cls, locale, page):
- return cls.localizable_file_filename(locale, page + '.json')
+ def locale_filename(self, locale, page):
+ config = self.read_config()
+ try:
+ page = config.get('locale_overrides', page)
+ except ConfigParser.Error:
+ pass
+ return self.localizable_file_filename(locale, page + '.json')
def list_locales(self):
result = set()
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()
- 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')
result = collections.OrderedDict()
if locale != default_locale:
result.update(self.read_locale(default_locale, page))
« no previous file with comments | « no previous file | tests/expected_output/de/translate » ('j') | tests/test_page_outputs.py » ('J')

Powered by Google App Engine
This is Rietveld