Opened 3 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#36681 closed Cleanup/optimization (fixed)

blocktranslate count plural example does not work for all languages (e.g. French 0 case)

Reported by: Sarah Boyce Owned by: Varun Kasyap Pentamaraju
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

https://docs.djangoproject.com/en/5.2/topics/i18n/translation/#blocktranslate-template-tag

In the blocktranslate docs, there is the following example:

{% blocktranslate count counter=list|length %}
There is only one {{ name }} object.
{% plural %}
There are {{ counter }} {{ name }} objects.
{% endblocktranslate %}

If list can be empty, the 0 case (which is plural in English) is not plural in all languages. 0 cats, 1 cat, 2 cats, 3 cats is 0 chat, 1 chat, 2 chats, 3 chats in French (notice that 0 is singular).
This means that the 0 case would say the French translation of There is only one {{ name }} object. as 0 is singular in French (and this would be a bug).

I believe the example should be updated to something like:

{% blocktranslate count counter=list|length %}
There is {{ counter }} {{ name }} object.
{% plural %}
There are {{ counter }} {{ name }} objects.
{% endblocktranslate %}

which would not lead to this issue.

Optionally we could add an admonition about plurals in different languages and that folks shouldn't assume that pluralization works the same as in English

Change History (10)

comment:1 by Jacob Walls, 3 weeks ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

Well spotted, Sarah!

comment:2 by Varun Kasyap Pentamaraju, 3 weeks ago

Owner: set to Varun Kasyap Pentamaraju
Status: newassigned

I would like to work on this

comment:3 by Varun Kasyap Pentamaraju, 3 weeks ago

Has patch: set

comment:4 by Jacob Walls, 3 weeks ago

Triage Stage: AcceptedReady for checkin
Version: 5.2dev

comment:5 by Jacob Walls, 3 weeks ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:6 by Varun Kasyap Pentamaraju, 3 weeks ago

Patch needs improvement: unset

PR: https://github.com/django/django/pull/19994

Patch:
1)used admonition instead of note
2)removed the non–Django/Python-related explanations
3) removed comma in "e.g."

Last edited 3 weeks ago by Varun Kasyap Pentamaraju (previous) (diff)

comment:7 by Jacob Walls, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:8 by Jacob Walls <jacobtylerwalls@…>, 2 weeks ago

Resolution: fixed
Status: assignedclosed

In 0ea0110:

Fixed #36681 -- Removed English pluralization bias from example in docs/topics/i18n/translation.txt.

comment:9 by Jacob Walls <jacobtylerwalls@…>, 2 weeks ago

In f13e6c90:

[6.0.x] Fixed #36681 -- Removed English pluralization bias from example in docs/topics/i18n/translation.txt.

Backport of 0ea01101c3a35568bc43e9707ac058b9874bd425 from main.

comment:10 by Jacob Walls <jacobtylerwalls@…>, 2 weeks ago

In 368f955:

[5.2.x] Fixed #36681 -- Removed English pluralization bias from example in docs/topics/i18n/translation.txt.

Backport of 0ea01101c3a35568bc43e9707ac058b9874bd425 from main.

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