Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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:

Description

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 3 years ago.
patch2.diff (19.0 KB) - added by szczav 3 years ago.

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by szczav

comment:1 Changed 3 years ago by szczav

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by russellm

  • Keywords blocker added
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

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 3 years ago by szczav

comment:3 Changed 3 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 3 years ago by russellm

  • milestone set to 1.3
  • Triage Stage changed from Accepted to Ready 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 3 years ago by russellm

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

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