diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index b8478354bd..25ca6f2471 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -447,16 +447,16 @@ def templatize(src, origin=None): for t in Lexer(src, origin).tokenize(): if incomment: if t.token_type == TOKEN_BLOCK and t.contents == 'endcomment': - content = u''.join(comment) + content = ''.join(comment) translators_comment_start = None for lineno, line in enumerate(content.splitlines(True)): if line.lstrip().startswith(TRANSLATOR_COMMENT_MARK): translators_comment_start = lineno for lineno, line in enumerate(content.splitlines(True)): if translators_comment_start is not None and lineno >= translators_comment_start: - out.write(u' # %s' % line) + out.write(' # %s' % line) else: - out.write(u' #\n') + out.write(' #\n') incomment = False comment = [] else: diff --git a/tests/regressiontests/i18n/commands/extraction.py b/tests/regressiontests/i18n/commands/extraction.py index 0d70d2641d..e5290406ab 100644 --- a/tests/regressiontests/i18n/commands/extraction.py +++ b/tests/regressiontests/i18n/commands/extraction.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- import os import re import shutil @@ -63,6 +64,9 @@ class BasicExtractorTests(ExtractorTests): self.assertTrue('#. Translators: One-line translator comment #4' in po_contents) self.assertTrue('#. Translators: Two-line translator comment #4\n#. continued here.' in po_contents) + self.assertTrue('#. Translators: One-line translator comment #5 -- with non ASCII characters: áéíóúö' in po_contents) + self.assertTrue('#. Translators: Two-line translator comment #5 -- with non ASCII characters: áéíóúö\n#. continued here.' in po_contents) + def test_templatize(self): os.chdir(self.test_dir) management.call_command('makemessages', locale=LOCALE, verbosity=0) diff --git a/tests/regressiontests/i18n/commands/templates/test.html b/tests/regressiontests/i18n/commands/templates/test.html index 86c7772580..b5d705c132 100644 --- a/tests/regressiontests/i18n/commands/templates/test.html +++ b/tests/regressiontests/i18n/commands/templates/test.html @@ -50,3 +50,10 @@ continued here. {% comment %} Translators: Two-line translator comment #4 continued here.{% endcomment %} {% trans "Translatable literal #4b" %} + +{% comment %} Translators: One-line translator comment #5 -- with non ASCII characters: áéíóúö{% endcomment %} +{% trans "Translatable literal #5a" %} + +{% comment %} Translators: Two-line translator comment #5 -- with non ASCII characters: áéíóúö +continued here.{% endcomment %} +{% trans "Translatable literal #6b" %}