Permissions don't get translated in admin interface

214 visningar
Hoppa till det första olästa meddelandet

Thibaud Colas

oläst,
24 sep. 2022 03:24:432022-09-24
till Django developers (Contributions to Django itself)
👋 there have been a lot of discussions and tickets opened on permissions translations in the past. I’m not sure what the etiquette here is, hence why I’m starting a new conversation.

I would like to see #1688 Permissions don't get translated in admin interface reconsidered, as to me it seems like a clear bug, which affects a lot of users. Though not many people might be managing permissions regularly, when you do, it’s very jarring that the text is in the wrong language.

I’m not sure what Django’s stance is on supporting non-english users generally, but based on our diversity statement I feel like "100% of the admin UI translated" is an important goal – and looking at Transifex, there are a lot of people putting in a lot of effort to get it there. If this is a wontfix because the store-label-in-DB approach is effectively impossible to make work, then I think this would be worth clearing documenting on the Localizing Django page so translators know what to expect. Ideally also mention elsewhere in a place visible to end users.

---

From a technical perspective, this is far from my area of expertise but as I understand there are clear solutions – one that’s "quick and dirty" would be to hard-code a list of gettext_lazy calls with the same labels as stored in the DB for the purpose of collecting the labels for PO files, and then we could use {% translate %} over the DB-provided values anyway. No change to the DB needed. I count 8 Django-provided models in my demo site (might be missing others), each has 4 Django-provided permissions, so that’s 32 strings to hard-code. Feels doable!


Danilov Maxim

oläst,
24 sep. 2022 18:28:482022-09-24
till django-d...@googlegroups.com

Hi, Tribaud.

 

In your case you can override Permission admin to show translated names of permissions and for widgets you can override modelchoiceiterator

The name of permission you can translate like model.verbose_name + gettext( ‘can’) + gettext(view/change/delete) and it should be translated.

With custom translation is a little bit  more work, but it also works.

I am not sure, that if override of __str__ helps, but it also possible.

 

 

By the way - My solution DJANGO-TOF 2.version solves you ask without any changes in code.

I‘ve presented it on last Django con 2022

We works with permissions and also custom permissions already long time in Multilanguage Project and I don’t see any problem with that.

 

 

Mit freundlichen Grüßen,

DI Mag. Maxim Danilov

 

+43(681)207 447 76

ma...@wpsoft.at

--
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/8e14c59f-3331-401a-85a1-cbf27d49fe65n%40googlegroups.com.

Sarah Baidoo

oläst,
24 sep. 2022 21:07:272022-09-24
till django-d...@googlegroups.com

Ramez Ashraf

oläst,
25 sep. 2022 07:12:212022-09-25
till Django developers (Contributions to Django itself)
Hello 

it's for this reason, i created this package https://github.com/RamezIssac/django-tabular-permissions
It displays the permissions in a table that is easily translated , and easier to work with

Aside from a 3rd party app, a workaround (like the one suggested above) will be the way to go.
For Django core, it think its very hard to do it as one can also have more than one non English of languages supported .. which permission language will be recorded in the database then ?

Screen shot for tabular permissions
tabular_permisions.png

Thibaud Colas

oläst,
25 sep. 2022 09:02:332022-09-25
till Django developers (Contributions to Django itself)
Thank you all for your suggestions so far :) Just to give a little bit more background – aside from ticket #1688 Permissions don't get translated in admin interface, this had also been discussed in Translation of group permissions on the mailing list (though it’s not just for groups).

To clarify what I’m after – in my opinion this needs to be treated as a bug to fix in Django itself – at least for translations of built-in permissions. Having a way to do this for custom ones would be nice too (see for example Wagtail issue #5341). So devising how to fix this would be nice, but right now this is officially a "wontfix" so this would need to be addressed first.

For reference, here is a screenshot of the current state, in Arabic (right-to-left language so the UI is partly mirrored):

translations-current-state.png

Translation names aren’t translated, while their model names are translated, and the app name isn’t translated ("auth" vs. app label "المصادقة والتفويض" in the sidebar).

Thibaud Colas

oläst,
14 okt. 2022 00:45:342022-10-14
till Django developers (Contributions to Django itself)
I worked on a potential fix for this yesterday at the Django London’s hack day with Nick (hi Nick if you’re reading this!). 
And here is a draft PR that makes those labels fully translate-able at least for the default permissions: https://github.com/thibaudcolas/django/pull/1

It seems to work well. As far as I could see, there’s no reason for at least the app name to be displayed in english (just need to switch from app_label to verbose_name).

Thibaud Colas

oläst,
2 juni 2023 11:37:172023-06-02
till Django developers (Contributions to Django itself)
👋 without further input, I’m not quite sure what to do with this. We need this ticket re-opened so anyone actually considers working on a fix for this. For reference, the initial reason for closing this bug report was:

The permissions are stored in the database and don't get translated.

To me at least this is a poor reason. First off this is still a clear bug from the perspective of people who expect the admin to be in the language of their choosing. Second, there are clear ways to improve upon this even without significantly re-engineering how permission names are generated (see message above – and my proof of concept).

Any takers? Should I post this elsewhere?

Mariusz Felisiak

oläst,
2 juni 2023 14:40:042023-06-02
till Django developers (Contributions to Django itself)
Is it not partly fixed by a52bdea5a27ba44b13eda93642231c65c581e083?

Thibaud Colas

oläst,
2 juni 2023 15:58:502023-06-02
till Django developers (Contributions to Django itself)
Ah-ha! Correct :) That’s great. So as of that commit, it’s just the permission names that aren’t translated. Here’s a screenshot of the current state:

permission-names-django-Django-5.0.dev20230602105440.png

I’ve updated my POC accordingly (https://github.com/thibaudcolas/django/pull/1), the implementation is still hacky but now only requires changes in the Permission model.

Thibaud Colas

oläst,
2 juni 2023 18:05:532023-06-02
till Django developers (Contributions to Django itself)
As suggested by @nessita on Discord, I’ve taken this to the Django Forum in Django Internals: https://forum.djangoproject.com/t/permissions-dont-get-translated-in-admin-interface/21324.

Let’s try to keep the discussion going over there!

Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden