Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#12903 closed (fixed)

Missing plural forms in admin

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

Description

Two strings are hard to translate, they don't have a plural form:

#: contrib/admin/templates/admin/actions.html:7
#, python-format
msgid ""
"<span class=\"_acnt\">0</span> of %(total_count)s %(module_name)s selected"
#: contrib/admin/templates/admin/actions.html:11
#, python-format
msgid "All %(total_count)s %(module_name)s selected"

Attachments (2)

12903-r12852.diff (9.0 KB) - added by ramiro 5 years ago.
A new tentative patch for this
12903-r12937.diff (9.0 KB) - added by ramiro 5 years ago.
New version of the patch, fixed a typo and changed method of passing a var from python to JS (hidden span -> JS var)

Download all attachments as: .zip

Change History (11)

comment:1 Changed 5 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

module_name already contains verbose_name or verbose_plural_name depending on the number of passed items. The span on line 7 is updated by Javascript so a plural form doesn't help. The note about having all items selected will only occur if having selected all items, plural.

comment:2 follow-up: Changed 5 years ago by stephaner

  • Resolution invalid deleted
  • Status changed from closed to reopened

You're wrong when you say 'if having selected all items, plural.' The plural form depends on the number of items, see http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html for an explanation.

Even more, if all items are selected, I can be only 1 of 1, and the translation becomes incorrect in French, eg. '1 parmi 1 « groupe » sélectionnés' must be '1 parmi 1 « groupe » sélectionné' (final 's' removed and I use French quotes to work around another orthographical problem).

comment:3 in reply to: ↑ 2 Changed 5 years ago by jezdez

  • Triage Stage changed from Unreviewed to Accepted

Replying to stephaner:

You're wrong when you say 'if having selected all items, plural.' The plural form depends on the number of items, see http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html for an explanation.

I'm aware how the plural form works, I just didn't see the special case of having just one item in the list.

Even more, if all items are selected, I can be only 1 of 1, and the translation becomes incorrect in French, eg. '1 parmi 1 « groupe » sélectionnés' must be '1 parmi 1 « groupe » sélectionné' (final 's' removed and I use French quotes to work around another orthographical problem).

Thanks for elaborating with the example, don't hesitate to work on a patch.

comment:4 Changed 5 years ago by jezdez

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

(In [12626]) Fixed #12903 - Added plural forms to a few strings in the admin actions template.

comment:5 Changed 5 years ago by stephaner

  • Resolution fixed deleted
  • Status changed from closed to reopened

My previous comment wasn't crystal clear, the fix is wrong because the plural form depends of the first argument, the number of selected items between span tag (not the second one, the number of results in the model).

The result in French is now:

1 parmi 5 sélectionnés
2 parmi 5 sélectionnés

but the right translation is:

1 parmi 5 sélectionné (plural form depends on first argument)
2 parmi 5 sélectionnés

The French translation will be even better with:

1 sélectionné parmi 5
2 sélectionnés parmi 5

We must give the full strings to the translators so they will be able to change the word ordering.
It isn't easy to provide the full string because the first argument is modified by Javascript code but may be, the full string could be moved Javascript side.

Changed 5 years ago by ramiro

A new tentative patch for this

comment:6 Changed 5 years ago by ramiro

  • Has patch set

Changed 5 years ago by ramiro

New version of the patch, fixed a typo and changed method of passing a var from python to JS (hidden span -> JS var)

comment:7 Changed 5 years ago by ramiro

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

Fixed in [12968].

comment:8 Changed 5 years ago by stephaner

Tested with success. Thank you!

comment:9 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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