Permissions don't get translated in admin interface

:wave: this is to discuss a potential re-opening (and fix?) of ticket #1688 Permissions don’t get translated in admin interface.

The issue was first reported in 2006. It was last raised by me in September 2022 on the django-developers mailing list after having found it in my own testing. There wasn’t much feedback on the mailing list. People suggested workarounds, while I want to make the case for this to be directly fixed in Django. On Discord, @nessita suggested taking the discussion to the forum. to see whether there might be more feedback here.

For people catching up on this – here is a good illustration of the problem as of Django main from today – translation names aren’t translated (while other parts of the label are):

As noted by @felixxm, this was recently improved thanks to a52bdea5a27ba44b13eda93642231c65c581e083.

I have worked on two proof-of-concept fixes here: thibaudcolas/django#1. The PoCs aren’t necessarily correct but (I think) demonstrate this can be fixed even while keeping translation names in the database.

A more brute-force approach would also be to simply duplicate the DB-stored strings in a file where they can be processed by makemessages, and pass the DB output to gettext.

So there are options to fix this – and first off I’d like to make the case for this ticket to be re-opened & accepted.

2 Likes

If we have reasonable options too fix then I’d be +1 to reopen.

Hi @thibaudcolas — thanks for the persistence here :medal_sports:

I agree that the reasons for closing don’t seem that great, so with a reasonable fix I’d be +1 too. (Surely it’s a good win if we can…)

2 Likes

I don’t have much experience with translations, but +1 since the PoC seems small and reasonable.

(What about extending to custom permissions? Users can’t easily override Permission.__str__…)

Hello! As mentioned in the Discord chat, I agree this functionality request makes sense and I feel we should revisit the topic with a more inclusive and open mind. So +1 from me!

Regarding solution, one idea that occurred to me is the following:

  • Could makemessages be extended so the permission labels are read from the DB and added as requiring translation to the proper .po file?
    Then translators would translate those permission labels (strings) as usual, and then we’d need some machinery to try to load translations for permission labels when displaying them in the UI.

This process could eventually be generalized to mark “any db column” as translatable, though I would certainly not go that far in an initial implementation.

Thanks, Natalia.

We have a 3rd-party package for this, see django-modeltranslation.

Ah, thanks for the pointer! I had no idea. So where does this leaves us/Django? Shall we aim at accepting the ticket and merging something along of the lines of what @thibaudcolas is proposing?

That sounds acceptable.