diff --git a/horizon/test/unit/utils/test_babel_extract_angular.py b/horizon/test/unit/utils/test_babel_extract_angular.py index f09b62879e..7aacf8ad2a 100644 --- a/horizon/test/unit/utils/test_babel_extract_angular.py +++ b/horizon/test/unit/utils/test_babel_extract_angular.py @@ -135,6 +135,15 @@ class ExtractAngularTestCase(test.TestCase): {$'some other thing'$}

{$'"it\\'s awesome"'|translate$}

{$"oh \\"hello\\" there"|translate$}

+ {$::'hello colon1' | translate $} +

{$ ::'hello colon2' |translate$}

+

{$ :: 'hello colon3'| translate$}

+ something {$::'hello colon4'|translate$} something
+            {$ ::'hello colon5' | translate$} + {::$expr()|translate$} + {$::'some other thing'$} +

{$:: '"it\\'s awesome"'|translate$}

+

{$ :: "oh \\"hello\\" there" | translate$}

""" ) @@ -147,6 +156,13 @@ class ExtractAngularTestCase(test.TestCase): (4, u'gettext', 'hello world4', []), (8, u'gettext', '"it\\\'s awesome"', []), (9, u'gettext', 'oh \\"hello\\" there', []), + (10, u'gettext', u'hello colon1', []), + (11, u'gettext', u'hello colon2', []), + (12, u'gettext', u'hello colon3', []), + (13, u'gettext', u'hello colon4', []), + (13, u'gettext', u'hello colon5', []), + (17, u'gettext', u'"it\\\'s awesome"', []), + (18, u'gettext', u'oh \\"hello\\" there', []), ], messages) diff --git a/horizon/utils/babel_extract_angular.py b/horizon/utils/babel_extract_angular.py index cd9ba5e274..4d06c271ef 100644 --- a/horizon/utils/babel_extract_angular.py +++ b/horizon/utils/babel_extract_angular.py @@ -21,7 +21,7 @@ from six.moves import html_parser # regex to find filter translation expressions filter_regex = re.compile( - r"""{\$\s*('([^']|\\')+'|"([^"]|\\")+")\s*\|\s*translate\s*\$}""" + r"""{\$\s*(::)?\s*('([^']|\\')+'|"([^"]|\\")+")\s*\|\s*translate\s*\$}""" ) # browser innerHTML decodes some html entities automatically, so when @@ -49,6 +49,8 @@ class AngularGettextHTMLParser(html_parser.HTMLParser): {$ 'content' | translate $} The string will be translated, minus expression handling (i.e. just bare strings are allowed.) + {$ ::'content' | translate $} + The string will be translated. As above. """ def __init__(self): @@ -94,7 +96,7 @@ class AngularGettextHTMLParser(html_parser.HTMLParser): for match in filter_regex.findall(attr[1]): if match: self.strings.append( - (self.line, u'gettext', match[0][1:-1], []) + (self.line, u'gettext', match[1][1:-1], []) ) def handle_data(self, data): @@ -103,7 +105,7 @@ class AngularGettextHTMLParser(html_parser.HTMLParser): else: for match in filter_regex.findall(data): self.strings.append( - (self.line, u'gettext', match[0][1:-1], []) + (self.line, u'gettext', match[1][1:-1], []) ) def handle_entityref(self, name):