Opened 16 years ago
Closed 15 years ago
#12201 closed (fixed)
django-admin.py makemessages could show the line number when it fails
| Reported by: | madewulf | Owned by: | nobody |
|---|---|---|---|
| Component: | Internationalization | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
For the following template file :
<p>{%blocktrans%}Dear {{worker}}{%blocktrans%}</p>
the command django-admin.py makemessages -lfr fails (because of the non closed blocktrans tag) without telling on which file it failed.
I just received the following, not very helpful, message :
Traceback (most recent call last):
File "/usr/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/var/lib/python-support/python2.6/django/core/management/__init__.py", line 331, in execute_from_command_line
utility.execute()
File "/var/lib/python-support/python2.6/django/core/management/__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/python-support/python2.6/django/core/management/base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
File "/var/lib/python-support/python2.6/django/core/management/base.py", line 219, in execute
output = self.handle(*args, **options)
File "/var/lib/python-support/python2.6/django/core/management/commands/makemessages.py", line 232, in handle
make_messages(locale, domain, verbosity, process_all, extensions)
File "/var/lib/python-support/python2.6/django/core/management/commands/makemessages.py", line 149, in make_messages
open(os.path.join(dirpath, thefile), "w").write(templatize(src))
File "/var/lib/python-support/python2.6/django/utils/translation/__init__.py", line 100, in templatize
return real_templatize(src)
File "/var/lib/python-support/python2.6/django/utils/translation/trans_real.py", line 478, in templatize
raise SyntaxError("Translation blocks must not include other block tags: %s" % t.contents)
SyntaxError: Translation blocks must not include other block tags: blocktrans
It would be more helpful to tell on which file the process failed, and if possible, at which line.
Attachments (4)
Change History (12)
comment:1 by , 16 years ago
| Summary: | django-admin.py makemessages fail without telling on which file it failed → django-admin.py makemessages fails without telling on which file it failed |
|---|
by , 16 years ago
| Attachment: | 12201-1.diff added |
|---|
comment:2 by , 16 years ago
| Has patch: | set |
|---|---|
| milestone: | → 1.2 |
| Version: | 1.0 → SVN |
comment:3 by , 16 years ago
It is strange you are aren't getting the file name in the error message because it was added back in April 2009 (r10538, #10234). Only explanation I can find is you are using some 1.0.x release.
I´ve taken it further to also show the line number but it needed some modifications to the inner parts of the Django templates Lexer. see attached patch.
comment:4 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:5 by , 16 years ago
| milestone: | 1.2 |
|---|---|
| Summary: | django-admin.py makemessages fails without telling on which file it failed → django-admin.py makemessages could show the line number when it fails |
- Changing summary to describe only the feature suggestion (show line number where the error is located) made by the OP whose fate hasn't been decided yet, the other one (show the name of the file with problems) has been fixed in since 1.1.
- Removing milestone 1.2 because this ticket doesn't meet the requirements at this stage of the release preparation process.
comment:6 by , 15 years ago
| Needs documentation: | set |
|---|---|
| Needs tests: | set |
comment:7 by , 15 years ago
| Needs tests: | unset |
|---|
I updated the patch to apply again on trunk, and I added a test. Does this really need documentation?
comment:8 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
A patch for this ticket. It changes Django templates Lexer.tokenize() to return a list of (token, lineno) tuples