Admin change list header for languages with grammatical cases

99 views
Skip to first unread message

Maciek Olko

unread,
May 21, 2021, 7:35:40 PM5/21/21
to django-d...@googlegroups.com
Admin’s change list headers are “Select {model} to change”, “Select {model} to view” or “Select {model}” (for pop-ups). We inject model’s verbose name in that strings. It renders correct strings for most of the languages, but not for those, which have grammatical cases [1] for nouns. Such languages include Polish, Greek, Russian, Hungarian, Czech and many more.

I try to track how many of languages are affected for selected nouns in a spreadsheet [2] with help of Google Translate.

To make the headers correct for this languages we should inject a verbose name into “Select {}[…]” sentences in a correct grammatical case. Effectively it is usually a word with changed ending comparing to a base form of a noun (verbose name value).

I’d like to propose a backwards compatible way to support an ability to provide a translation for a grammatical case of model’s verbose name and “selecting” to use it in a translation string.

In short the implementation requires:
  • switching from %-string formatting to format-strings in admin’s changelist headers source strings,
  • adding a class that will behave like string, but also let access it’s attributes,
  • leveraging accessing attributes in Python format-string syntax.

I don’t have enough means to confirm it for all languages, but my cursory research says that probably the case used in “Select {}” sentence is an accusative for all languages that have grammatical cases.

I would like that feature to be in Django as currently the admin changelist header translation, with model name not inflected, in Polish (“Wybierz użytkownik do zmiany”) sounds awkwardly and incorrectly. I'd assume for other such languages the situation is similar. Bringing grammatical cases there would be a great step towards perfection (that should attract perfectionists :) ) in admin for languages like Czech, Greek, Hungarian and many more.

I didn’t post a ticket nor created a pull request yet, as I’d like to consult it with the community beforehand, according to the best practices.

Would you accept such a functionality in the Django project?

Best regards,
Maciej Olko

PS. There is a ticket about bringing gettext plurals into model’s verbose name [3] loosly connected with this particular topic, but the discussion underneath touches also the topic of grammatical cases.

[1] https://en.wikipedia.org/wiki/Grammatical_case
[2] https://docs.google.com/spreadsheets/d/1GfdCMvqCdg1c2fTf940r8yEnCiXr9s86p0JbGRV4Aio
[3] https://code.djangoproject.com/ticket/11688

Maciek Olko

unread,
May 21, 2021, 8:54:50 PM5/21/21
to django-d...@googlegroups.com
I forgot to mention that my implementation extensively uses gettext context functionality [1]. I am happy to comment on and discuss particular parts of the implementation.

The implementation is quite general, it does not limit the use of attributes and contexts to only grammatical cases.

I decided to use "accusative" for attribute and context name hoping that all languages will use base verbose name case or accusative grammatical case. But on the other hand context/attribute name "changelist title" would be probably equally good (the former would be better, if there would be more uses than in changelist title only).

I think there comes natural expectation that similar mechanism would work also in Django templates. That may be impossible because of dynamic nature of this feature and serialization needed for safety and portability in templates, although I'm not yet 100% sure.

Regards,
Maciej

Ramez Ashraf

unread,
May 24, 2021, 4:18:36 AM5/24/21
to Django developers (Contributions to Django itself)
Thank you for bringing this up

Arabic is one of those language, the issue comes with masculine and feminine nouns.
" Select {model} to change"
If model noun is masculine then it's ok... if a feminine one then it's not correct.

Example: 
Correct أختر مقال لتغييره 
Wrong/awkward  اختر هيئه لتغييره 
should be اختر هيئه لتغييرها

i work around that by adding both .لتغييره(ها)
An other approach is change the text to 
Select {model} record to change
Because now change verb will be to a record which is a masculine noun regardless of the model.

Thanks for bringing this up again.

Maciek Olko

unread,
May 24, 2021, 4:52:15 PM5/24/21
to django-d...@googlegroups.com
Thank you Ramez,

Could you confirm that grammatical case in Arabic in case of this sentence ("Select {}") it is an accusative (المنصوب)?

https://arabic.desert-sky.net/g_cases.html#acc

Kind regards,
Maciej

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/6ffacfc1-f8f9-484a-8869-cc5745be92fcn%40googlegroups.com.

Ramez Ashraf

unread,
May 25, 2021, 12:57:11 AM5/25/21
to Django developers (Contributions to Django itself)
Yep Confirm.
Reply all
Reply to author
Forward
0 new messages