Merge "i18n: trim whitespaces in extracted messages from AngularJS templates"

This commit is contained in:
Jenkins 2016-07-08 12:31:35 +00:00 committed by Gerrit Code Review
commit ccbad83a17
2 changed files with 5 additions and 4 deletions

View File

@ -159,7 +159,7 @@ class ExtractAngularTestCase(test.TestCase):
"</translate></html>") "</translate></html>")
messages = list(extract_angular(buf, [], [], {})) messages = list(extract_angular(buf, [], [], {}))
self.assertEqual([(1, 'gettext', 'hello\n world!', [])], messages) self.assertEqual([(1, 'gettext', 'hello world!', [])], messages)
def test_nested_translate_tag(self): def test_nested_translate_tag(self):
buf = StringIO( buf = StringIO(

View File

@ -15,6 +15,7 @@
import re import re
from django.utils.translation import trim_whitespace
from six.moves import html_parser from six.moves import html_parser
@ -126,12 +127,12 @@ class AngularGettextHTMLParser(html_parser.HTMLParser):
return return
if self.plural_form: if self.plural_form:
messages = ( messages = (
self.data.strip(), trim_whitespace(self.data.strip()),
self.plural_form trim_whitespace(self.plural_form)
) )
func_name = u'ngettext' func_name = u'ngettext'
else: else:
messages = self.data.strip() messages = trim_whitespace(self.data.strip())
func_name = u'gettext' func_name = u'gettext'
self.strings.append( self.strings.append(
(self.line, func_name, messages, self.comments) (self.line, func_name, messages, self.comments)