mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
[1.3.X] Fixed #15848 -- Fixed regression introduced in [15882] in makemessages management command when processing multi-line comments that contain non-ASCCI characters in templates. Thanks for the report Denis Drescher.
Backport of r16038/r16039 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16040 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9b21a0c921
commit
1d499d50d0
@ -447,16 +447,16 @@ def templatize(src, origin=None):
|
|||||||
for t in Lexer(src, origin).tokenize():
|
for t in Lexer(src, origin).tokenize():
|
||||||
if incomment:
|
if incomment:
|
||||||
if t.token_type == TOKEN_BLOCK and t.contents == 'endcomment':
|
if t.token_type == TOKEN_BLOCK and t.contents == 'endcomment':
|
||||||
content = u''.join(comment)
|
content = ''.join(comment)
|
||||||
translators_comment_start = None
|
translators_comment_start = None
|
||||||
for lineno, line in enumerate(content.splitlines(True)):
|
for lineno, line in enumerate(content.splitlines(True)):
|
||||||
if line.lstrip().startswith(TRANSLATOR_COMMENT_MARK):
|
if line.lstrip().startswith(TRANSLATOR_COMMENT_MARK):
|
||||||
translators_comment_start = lineno
|
translators_comment_start = lineno
|
||||||
for lineno, line in enumerate(content.splitlines(True)):
|
for lineno, line in enumerate(content.splitlines(True)):
|
||||||
if translators_comment_start is not None and lineno >= translators_comment_start:
|
if translators_comment_start is not None and lineno >= translators_comment_start:
|
||||||
out.write(u' # %s' % line)
|
out.write(' # %s' % line)
|
||||||
else:
|
else:
|
||||||
out.write(u' #\n')
|
out.write(' #\n')
|
||||||
incomment = False
|
incomment = False
|
||||||
comment = []
|
comment = []
|
||||||
else:
|
else:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@ -63,6 +64,9 @@ class BasicExtractorTests(ExtractorTests):
|
|||||||
self.assertTrue('#. Translators: One-line translator comment #4' in po_contents)
|
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: 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):
|
def test_templatize(self):
|
||||||
os.chdir(self.test_dir)
|
os.chdir(self.test_dir)
|
||||||
management.call_command('makemessages', locale=LOCALE, verbosity=0)
|
management.call_command('makemessages', locale=LOCALE, verbosity=0)
|
||||||
|
@ -50,3 +50,10 @@ continued here.
|
|||||||
{% comment %} Translators: Two-line translator comment #4
|
{% comment %} Translators: Two-line translator comment #4
|
||||||
continued here.{% endcomment %}
|
continued here.{% endcomment %}
|
||||||
{% trans "Translatable literal #4b" %}
|
{% 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" %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user