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

Unified Diff: cms/converters.py

Issue 6440550915899392: Issue 2139 - Allow nested translations for tag attributes. (Closed)
Patch Set: Use complex regexp instead of keeping track of nested levels ourselves. Created April 21, 2015, 2:43 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/converters.py
diff --git a/cms/converters.py b/cms/converters.py
index b853f78c4eb0625671a797a6640006c772929ad6..0fbfebadc2e3904e5428cd95292679bb8fbf1fc2 100644
--- a/cms/converters.py
+++ b/cms/converters.py
@@ -145,6 +145,7 @@ class Converter:
# Insert attributes
result = escape(result)
def stringify_attribute((name, value)):
+ value = self.insert_localized_strings(value, escapes)
if name == "href":
link_locale, link = self._params["source"].resolve_link(value, locale)
if link:
@@ -177,7 +178,12 @@ class Converter:
return self.localize_string(name, default, self._params["localedata"], escapes)
return re.sub(
- r"\{\{\s*([\w\-]+)(?:\[(.*?)\])?\s+(.*?)\}\}",
+ r"\{\{\s*"
+ r"([\w\-]+)" # String ID
+ r"(?:\[(.*?)\])?" # Optional comment
+ r"\s+"
+ r"((?:[^\{]|\{(?!\{)|\{\{(?:[^\}]|\}(?!\}))*?\}\})*?)" # Translatable text
+ r"\}\}",
lookup_string,
text,
flags=re.S
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld