Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15632 closed (fixed)

django-admin.py makemessages failure on ' symbol in templates comment block

Reported by: andrew@… Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords: xgettext
Cc: steve@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

django-admin.py makemessages fails on mezzanine.core application default admin/base_site.html template (attachment:base_site.html)

$ django-admin.py makemessages -l ru
processing language ru
Error: errors happened while running xgettext on base_site.html
./templates/admin/base_site.html.py:15: warning: unterminated string
./templates/admin/base_site.html.py:16: warning: unterminated string
./templates/admin/base_site.html.py:21: warning: unterminated string

It caused by xgettext when it see "Mezzanine's" string in this lines. In django v1.2 error doesn't appears.

Attachments (4)

base_site.html (8.1 KB) - added by andrew@… 3 years ago.
15632-1.diff (2.6 KB) - added by claudep 3 years ago.
Handle properly multiline translator comments
15632-2.diff (2.7 KB) - added by claudep 3 years ago.
Same patch which doesn't replace newlines (following ramiro's idea)
15632-5.diff (5.1 KB) - added by ramiro 3 years ago.
New patch for the issue -- preseves line numbers in .po file comments, expanded tests

Download all attachments as: .zip

Change History (13)

Changed 3 years ago by andrew@…

comment:1 Changed 3 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Which version of gettext do you use? Running xgettext --version should give you that info.

comment:2 Changed 3 years ago by andrew@…

xgettext (GNU gettext-tools) 0.18.1

comment:3 Changed 3 years ago by jezdez

Hm, this is probably related to #14045 and #15495. Can you check with gettext 0.17?

comment:4 Changed 3 years ago by andrew@…

  • Keywords xgettext added

Same situation with gettext 0.17.

[grad@grad-book core]$ LANG=C xgettext --version
xgettext (GNU gettext-tools) 0.17
...

[grad@grad-book core]$ LANG=C PYTHONPATH=/home/grad/repos/django /home/grad/repos/django/django/bin/django-admin.py --version
1.3 rc 1 SVN-15876
[grad@grad-book core]$ LANG=C PYTHONPATH=/home/grad/repos/django /home/grad/repos/django/django/bin/django-admin.py makemessages -l ru
processing language ru
Error: errors happened while running xgettext on base_site.html
./templates/admin/base_site.html.py:15: warning: unterminated string
./templates/admin/base_site.html.py:16: warning: unterminated string
./templates/admin/base_site.html.py:21: warning: unterminated string

[grad@grad-book core]$ LANG=C django-admin.py --version
1.2.5
[grad@grad-book core]$ LANG=C django-admin.py makemessages -l ru
processing language ru
[grad@grad-book core]$ echo $?
0

comment:5 Changed 3 years ago by andrew@…

Is there any way to see content of ./templates/admin/base_site.html.py file? Does django any change in template before passing it to xgettext?

Changed 3 years ago by claudep

Handle properly multiline translator comments

Changed 3 years ago by claudep

Same patch which doesn't replace newlines (following ramiro's idea)

comment:6 Changed 3 years ago by claudep

  • Has patch set
  • Triage Stage changed from Unreviewed to Accepted

Changed 3 years ago by ramiro

New patch for the issue -- preseves line numbers in .po file comments, expanded tests

comment:7 Changed 3 years ago by ramiro

15632-5.diff is a further evolution of the patch we were discussing with Claude on IRC. I wasn't comfortable with ignoring the multi-line comments in templates because that means we get non-accurate line numbers #: path/to/template/file.html:NN comments in the PO files, so this patch also solves this. Tests were also expanded to cover some edge cases.

comment:8 Changed 3 years ago by ramiro

  • Resolution set to fixed
  • Status changed from new to closed

In [15882]:

Fixed #15632 -- Ignore unrelated content in template multi-line comment blocks when looking for tokens that identify comments for translators. Thanks andrew AT ie-grad DOT ru for the report and Claude Paroz for spotting the problem and helping to fix it.

comment:9 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.