Using messages pluralization instead of model_ngettext() function

Hi,

I want to propose removing model_ngettext() function and using pluralization of messages with selecting the right placeable inside the message instead.

  • The model_ngettext() function doesn’t really serve it’s purpose – it only supports English plurals with “one” and “more” options – it is called with verbose_name and verbose_name_plurals which in case of internationalized applications will render as already translated names, moreover we do not use ngettext_noop anywhere that would let us add a new needed key translations for model names.
  • Even if we would fix its implementation, use of it would differ between the messages, meaning we should also then differentiate context of messages. For example in Polish: in message “Cannot delete %(name)s” we would use the accusative of plural always (for count of 2 and of 5, we’d like to have “Nie można usunąć grup”), whereas in “Successfully deleted %(count)d %(item)s.” we would make use of plural forms (“Pomyślnie usunięto 2 grupy.”/“Pomyślnie usunięto 5 grup.”).

I’d like to bring to your attention PR https://github.com/django/django/pull/14690 with the changes I’d like to consult with you.

There is also my past, abandoned PR for “fixing” the model_ngettext: https://github.com/django/django/pull/14465.

And the ticket discussion at #32797 (model_ngettext incorrectly tries to translate already translated words) – Django.

Kind regards,
Maciej

1 Like