#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 , 3 weeks ago
| Easy pickings: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:4 by , 3 weeks ago
| Triage Stage: | Accepted → Ready for checkin |
|---|---|
| Version: | 5.2 → dev |
comment:5 by , 3 weeks ago
| Patch needs improvement: | set |
|---|---|
| Triage Stage: | Ready for checkin → Accepted |
comment:6 by , 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) changes removed comma in "e.g."
comment:7 by , 3 weeks ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Well spotted, Sarah!