Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15287 closed (fixed)

Error messages in generic views are partialy translated

Reported by: szczav Owned by: nobody
Component: Generic views Version: master
Severity: Keywords: generic views http404 translation error blocker
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:


Http404 error messages in class based generic views are not translated, but model names passed to them are. Example:

raise Http404("No %s available" % model._meta.verbose_name)

Messages should be translated completely or not translated at all. As I see in Django source code they are almost always not translated. I think that model._meta.verbose_name should be replaced by model._meta.object_name.

It's related with #12418.

Attachments (2)

patch.diff (4.3 KB) - added by szczav 7 years ago.
patch2.diff (19.0 KB) - added by szczav 7 years ago.

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by szczav

Attachment: patch.diff added

comment:1 Changed 7 years ago by szczav

Has patch: set

comment:2 Changed 7 years ago by Russell Keith-Magee

Keywords: blocker added
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Accepting the issue, but I lean towards the other proposed solution -- taking contrib.admin as an example, 404 messages should be translated.

Also marking this as a blocker because we should get translation strings sorted in the initial public version.

Changed 7 years ago by szczav

Attachment: patch2.diff added

comment:3 Changed 7 years ago by szczav

In second patch I translated all error messages in generic class views according to russellm's suggestion. I think that it would be good to do some additional tests for errors, but I don't have time to do it now.

comment:4 Changed 7 years ago by Russell Keith-Magee

milestone: 1.3
Triage Stage: AcceptedReady for checkin

This patch isn't strictly ready for checkin, because it's a superset of what is needed. However, I can distill what is needed from this patch. For posterity:

  • We're not going to add translation strings for deprecated features (i.e., old-style function based generics)
  • We don't need to translate InvalidConfiguration, TypeError and other internal errors. If a user ever sees these, there is something *badly* wrong. We only need to translate the 404s. This follows the pattern established by contrib.admin.

comment:5 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

In [15533]:

Fixed #15287 -- Added translation markers to user-facing error messages in class-based generic views. Thanks to szczav for the report and draft patch.

comment:6 Changed 7 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top