summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-05-27 09:24:22 +0000
committerGerrit Code Review <review@openstack.org>2019-05-27 09:24:22 +0000
commit2a26c6a8033e499d1565d9c9f9d138979e1c7149 (patch)
treebff91aefc27e64d7d90d520119bfb27529094c48
parentd9dc8340fbf4dbfcb771383a0e741d53e2d105bd (diff)
parent6407c81be001b6ddeb788645f0a087b40ff67986 (diff)
downloadhorizon-2a26c6a8033e499d1565d9c9f9d138979e1c7149.tar.gz
Merge "Complete angular translation extract pattern" into stable/queens
-rw-r--r--horizon/test/unit/utils/test_babel_extract_angular.py16
-rw-r--r--horizon/utils/babel_extract_angular.py8
2 files changed, 21 insertions, 3 deletions
diff --git a/horizon/test/unit/utils/test_babel_extract_angular.py b/horizon/test/unit/utils/test_babel_extract_angular.py
index f09b62879..7aacf8ad2 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):
<img alt="{$'some other thing'$}">
<p>{$'"it\\'s awesome"'|translate$}</p>
<p>{$"oh \\"hello\\" there"|translate$}</p>
+ <img alt="{$::'hello colon1' | translate $}">
+ <p>{$ ::'hello colon2' |translate$}</p>
+ <p>{$ :: 'hello colon3'| translate$}</p>
+ <img alt="something {$::'hello colon4'|translate$} something
+ {$ ::'hello colon5' | translate$}">
+ <img alt="{::$expr()|translate$}">
+ <img alt="{$::'some other thing'$}">
+ <p>{$:: '"it\\'s awesome"'|translate$}</p>
+ <p>{$ :: "oh \\"hello\\" there" | translate$}</p>
"""
)
@@ -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 ff517cedc..8281ef7d9 100644
--- a/horizon/utils/babel_extract_angular.py
+++ b/horizon/utils/babel_extract_angular.py
@@ -20,7 +20,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
@@ -48,6 +48,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):
@@ -93,7 +95,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):
@@ -102,7 +104,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):