Revert "i18n: trim whitespaces in extracted messages"

This reverts commit f87b58fcab.
In https://bugs.launchpad.net/horizon/+bug/1592965,
extracted messages are stored with trimming.
After this change, strings with multi lines cannot be translated.

This change cause the difference between the real strings in html
and a key in pot, from the view point of extra spaces and break lines.
Message extraction is done by babel (with horizon specific extractor),
but translation message lookup is done by angular-gettext.
As a result, a key used in translation lookup becomes different from
a key generated by the message extraction.
Keys in both steps should be same.
So this patch reverts the corresponding commit to make translation
work, even though it may be annoying for translators again.

Regarding the comment from i18n perspective, see Akihiro's comment
in patch set 3 in https://review.openstack.org/#/c/347725

Closes-Bug: #1606837
Change-Id: I651a2f39fdc0209f702cb9cf45691c944382b897
This commit is contained in:
Kenji Ishii 2016-08-02 11:26:14 +09:00 committed by Akihiro Motoki
parent f9ba1ecc2f
commit 5e00cc5e92
2 changed files with 4 additions and 5 deletions

View File

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

View File

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