Opened 10 years ago
Last modified 2 weeks ago
#12367 new defect
Tickets admin: “Remove selected items” yields mistranslated error message when no item selected, logged as HTTP 500
| Reported by: | Jun Omae | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | unscheduled |
| Component: | ticket system | Version: | |
| Severity: | minor | Keywords: | i18n admin |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description (last modified by )
In /admin/ticket/priority page, Remove selected items with no selection shows the following message in French:
Aucun priority sélectionné
priority text is untranslated…
2016-02-26 19:27:04,572 Trac[main] WARNING: [192.168.11.11] HTTPInternalError: 500 Erreur Trac (Aucun priority sélectionné)
It would be good to add localized message for each enum value of ticket.
-
trac/ticket/admin.py
diff --git a/trac/ticket/admin.py b/trac/ticket/admin.py index acd9d4ec5..ef410cbb7 100644
a b class AbstractEnumAdminPanel(TicketAdminPanel): 599 599 600 600 _type = 'unknown' 601 601 _enum_cls = None 602 _no_item_selected = None 602 603 603 604 # TicketAdminPanel methods 604 605 … … class AbstractEnumAdminPanel(TicketAdminPanel): 651 652 elif req.args.get('remove'): 652 653 sel = req.args.get('sel') 653 654 if not sel: 654 raise TracError( _("No %s selected") % self._type)655 raise TracError(gettext(self._no_item_selected)) 655 656 if not isinstance(sel, list): 656 657 sel = [sel] 657 658 with self.env.db_transaction: … … class PriorityAdminPanel(AbstractEnumAdminPanel): 789 790 _type = 'priority' 790 791 _enum_cls = model.Priority 791 792 _label = (N_('Priority'), N_('Priorities')) 793 _no_item_selected = N_("No priority selected") 792 794 793 795 794 796 class ResolutionAdminPanel(AbstractEnumAdminPanel): 795 797 _type = 'resolution' 796 798 _enum_cls = model.Resolution 797 799 _label = (N_('Resolution'), N_('Resolutions')) 800 _no_item_selected = N_("No resolution selected") 798 801 799 802 800 803 class SeverityAdminPanel(AbstractEnumAdminPanel): 801 804 _type = 'severity' 802 805 _enum_cls = model.Severity 803 806 _label = (N_('Severity'), N_('Severities')) 807 _no_item_selected = N_("No severity selected") 804 808 805 809 806 810 class TicketTypeAdminPanel(AbstractEnumAdminPanel): 807 811 _type = 'type' 808 812 _enum_cls = model.Type 809 813 _label = (N_('Ticket Type'), N_('Ticket Types')) 814 _no_item_selected = N_("No ticket type selected") 810 815 811 816 _command_type = 'ticket_type' 812 817 _command_help = {
Attachments (0)
Change History (10)
comment:1 by , 10 years ago
follow-up: 6 comment:2 by , 10 years ago
This is an aside related to one of the lines that has been changed in the proposed patch. The line is:
_("No %s selected") % self._type
whereas usually we would write that as:
_("No %(type)s selected", type=self._type)
I imagine that %(type)s is a better hint to translations, as opposed to %s. Are there any other impacts of using the former rather than the latter?
One reason I ask is that I see the former pattern used at many places in SpamFilter. One such place I corrected in [14836], to follow the more typical pattern we see in Trac. However, I was unable to find any positive or negative functional effects of this change.
comment:3 by , 9 years ago
| Milestone: | next-stable-1.0.x → next-stable-1.2.x |
|---|
Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.
comment:4 by , 6 years ago
| Milestone: | next-stable-1.2.x → next-stable-1.4.x |
|---|
comment:6 by , 3 weeks ago
Replying to Ryan J Ollos:
[…] I imagine that
%(type)sis a better hint to translations, as opposed to%s. Are there any other impacts of using the former rather than the latter?
In this case, no, but in general, the current form is much more fragile than the one you suggest. This is not inherent to the % operator, but rather to usage of positional parameters instead of named parameters. Positional parameters are much more prone to mixes when text changes or when the translation uses a different phrase structure.
follow-up: 9 comment:7 by , 3 weeks ago
| Description: | modified (diff) |
|---|---|
| Milestone: | next-stable-1.6.x → unscheduled |
| Summary: | Error message with untranslated text when removing no selected items → Tickets admin: “Remove selected items” yiels mistranslated error message when no item selected, logged as HTTP 500 |
Thank you for reporting
There are 2 issues here:
- The partial translation of the message.
- Logging of a 500 error in such cases.
The proposed patch solves #1 the issue, but to the cost of significant burden for translators. I would rather suggest:
- Making that error unlikely/abnormal, perhaps by making the button disabled until items are selected, or by switching to individual removals
- Should the error happen nevertheless, use a generic message (“No item selected; nothing removed”)
As for the second problem, if we cannot prevent such requests, change the code to 400.
This comment is from Philippe "Chealer" Cloutier. I am subscribing to this ticket, but notifications seem to be broken, and I struggle to display my full email address or link to my contact information from this comment. My email address is available on Kune ni povos’s contact page. All of my comments and contributions in this ticket are offered under the terms of CC0 1.0 (unless otherwise noted).
comment:8 by , 3 weeks ago
| Summary: | Tickets admin: “Remove selected items” yiels mistranslated error message when no item selected, logged as HTTP 500 → Tickets admin: “Remove selected items” yields mistranslated error message when no item selected, logged as HTTP 500 |
|---|---|
| Version: | → 1.6 |
comment:9 by , 2 weeks ago
comment:10 by , 2 weeks ago
| Version: | 1.6 |
|---|



It's probably a good intermediate step until we finally tackle the TracDev/Proposals/ConfigEnumTranslation issue.