[Feature request] Allow grammatical cases for verbose_names

47 views
Skip to first unread message

Maciek Olko

unread,
Jan 7, 2019, 8:23:54 PM1/7/19
to django-d...@googlegroups.com
Django calls itself a framework for perfectionists, whereas isn’t perfect for locale Django admin in languages with grammatical cases. Please find a description of an idea of one step towards perfection below.

PEP 3101 introduced compound field names in string formatting for Python 2.7 and 3.2+. We can use it together with pgettext (gettext with context) to allow use of grammatical cases in Django admin translation texts.

If Meta.verbose_name was object of class Noun, we could translate a title of model changelist view from `Select {} to change` to e.g. (pl) `Wybierz {.accusative} do zmiany` (correct grammatical case for Polish).

Verbose name definition in Group model needed would be:

verbose_name = Noun(pgettext(‘nominative’, ‘group’), accusative=pgettext(‘accusative’, ‘group’))

For backward compatibility, we could wrap existing verbose_names behind the scenes with Noun with only one grammatical case, and fallback all other grammatical cases to first and standard case (covers also compatibility for lack of translations for grammatical cases).

Before completing the feature I would try to figure out minimal set of grammatical cases for Django admin and Django locale languages that uses grammatical cases to enable use of those cases in translations strings.

AFAIK this change would involve a couple of changes in Django core, but can be fully backward compatible.

I am willing to implement the solution myself, if only I will have enough free time.

I would be very happy to receive any feedback.

Also feel free to supplement potential Django issue description for the case: https://docs.google.com/document/d/16uEnKyiO9mn66JI64RtmMrEY_fyG2tWbI7OZIFE880o/edit

Regards,
Maciej
Reply all
Reply to author
Forward
0 new messages