Edgewall Software
Modify

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 Philippe Cloutier <chealer@…>)

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):  
    599599
    600600    _type = 'unknown'
    601601    _enum_cls = None
     602    _no_item_selected = None
    602603
    603604    # TicketAdminPanel methods
    604605
    class AbstractEnumAdminPanel(TicketAdminPanel):  
    651652                elif req.args.get('remove'):
    652653                    sel = req.args.get('sel')
    653654                    if not sel:
    654                         raise TracError(_("No %s selected") % self._type)
     655                        raise TracError(gettext(self._no_item_selected))
    655656                    if not isinstance(sel, list):
    656657                        sel = [sel]
    657658                    with self.env.db_transaction:
    class PriorityAdminPanel(AbstractEnumAdminPanel):  
    789790    _type = 'priority'
    790791    _enum_cls = model.Priority
    791792    _label = (N_('Priority'), N_('Priorities'))
     793    _no_item_selected = N_("No priority selected")
    792794
    793795
    794796class ResolutionAdminPanel(AbstractEnumAdminPanel):
    795797    _type = 'resolution'
    796798    _enum_cls = model.Resolution
    797799    _label = (N_('Resolution'), N_('Resolutions'))
     800    _no_item_selected = N_("No resolution selected")
    798801
    799802
    800803class SeverityAdminPanel(AbstractEnumAdminPanel):
    801804    _type = 'severity'
    802805    _enum_cls = model.Severity
    803806    _label = (N_('Severity'), N_('Severities'))
     807    _no_item_selected = N_("No severity selected")
    804808
    805809
    806810class TicketTypeAdminPanel(AbstractEnumAdminPanel):
    807811    _type = 'type'
    808812    _enum_cls = model.Type
    809813    _label = (N_('Ticket Type'), N_('Ticket Types'))
     814    _no_item_selected = N_("No ticket type selected")
    810815
    811816    _command_type = 'ticket_type'
    812817    _command_help = {

Attachments (0)

Change History (10)

comment:1 by Christian Boos, 10 years ago

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

comment:2 by Ryan J Ollos, 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 Ryan J Ollos, 9 years ago

Milestone: next-stable-1.0.xnext-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 Ryan J Ollos, 6 years ago

Milestone: next-stable-1.2.xnext-stable-1.4.x

comment:5 by Ryan J Ollos, 2 years ago

Milestone: next-stable-1.4.xnext-stable-1.6.x

Milestone renamed

in reply to:  2 comment:6 by Philippe Cloutier <chealer@…>, 3 weeks ago

Replying to Ryan J Ollos:

[…] 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?

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.

comment:7 by Philippe Cloutier <chealer@…>, 3 weeks ago

Description: modified (diff)
Milestone: next-stable-1.6.xunscheduled
Summary: Error message with untranslated text when removing no selected itemsTickets 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:

  1. The partial translation of the message.
  2. 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:

  1. Making that error unlikely/abnormal, perhaps by making the button disabled until items are selected, or by switching to individual removals
  2. 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).

Last edited 3 weeks ago by Jun Omae (previous) (diff)

comment:8 by Philippe Cloutier <chealer@…>, 3 weeks ago

Summary: Tickets admin: “Remove selected items” yiels mistranslated error message when no item selected, logged as HTTP 500Tickets admin: “Remove selected items” yields mistranslated error message when no item selected, logged as HTTP 500
Version: 1.6

in reply to:  7 comment:9 by Jun Omae, 2 weeks ago

  1. Making that error unlikely/abnormal, perhaps by making the button disabled until items are selected, or by switching to individual removals

Already fixed in [12450] (#11056, Trac 1.1.2).

comment:10 by Jun Omae, 2 weeks ago

Version: 1.6

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.