Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10234 closed (fixed)

makemessages.py SyntaxErrors are hard to track because they don't say which template or file it happened in

Reported by: peterbe Owned by: andrewbadr
Component: Internationalization Version: master
Severity: Keywords: django-admin
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

I ran django-admin.py makemessages -l sv and it turns out that I had forgotten the 'end' on {% endblocktrans %} so it threw this error:

SyntaxError: Translation blocks must not include other block tags: blocktrans

If you have many files with blocktrans in them it's hard to know where you've make the syntax error.
I patched makemessages.py to also include the filename into error message. Now the error message looks like this instead:

SyntaxError: Translation blocks must not include other block tags: blocktrans (file: ./search/templates/500.html)

Attachments (2)

makemessages.py.diff (402 bytes) - added by peterbe 5 years ago.
belongs in django/core/management/commands/
makemessages_t10234_r10177.diff (1.2 KB) - added by andrewbadr 5 years ago.
Same patch, corrected format

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by peterbe

belongs in django/core/management/commands/

comment:1 follow-up: Changed 5 years ago by peterbe

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

Noticed that when you download the .diff file or when you try to view it here on Trac it shows as just one line. Weird.

comment:2 in reply to: ↑ 1 Changed 5 years ago by ramiro

  • Patch needs improvement set

Replying to peterbe:

Noticed that when you download the .diff file or when you try to view it here on Trac it shows as just one line. Weird.

The patch contents looks mostly ok when you download it. Please generate it from the root of the django tree so the .diff header contains the django/core/management/commands/makemessages.py path. Also, specify the -u (unified) to diff, this will solve the Trac display problem.

This is described at http://docs.djangoproject.com/en/dev/internals/contributing/#patch-style.

Thanks for you contribution!

comment:3 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 5 years ago by andrewbadr

  • Owner changed from nobody to andrewbadr

Going to duplicate the original patch

Changed 5 years ago by andrewbadr

Same patch, corrected format

comment:5 Changed 5 years ago by mtredinnick

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

(In [10538]) Fixed #10234 -- Improved error message when internationalizing templates.

Patch from peterbe and Andrew Badr.

comment:6 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 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.