Opened 6 hours ago

#36681 new Cleanup/optimization

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

Reported by: Sarah Boyce Owned by:
Component: Documentation Version: 5.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no 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 (0)

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