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!). 

   - Here is where translation names get 
   created: 
https://github.com/django/django/blob/main/django/contrib/auth/management/__init__.py#L31
   - And where the strings are generated for 
   display: 
https://github.com/django/django/blob/main/django/contrib/auth/models.py#L78
   - As well 
   as: 
https://github.com/django/django/blob/main/django/contrib/contenttypes/models.py#L150

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).
On Sunday, 25 September 2022 at 14:02:33 UTC+1 Thibaud Colas wrote:

> 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 <https://code.djangoproject.com/ticket/1688>, 
> this had also been discussed in Translation of group permissions 
> <https://groups.google.com/g/django-developers/c/w93rJrPTPy0/m/1XfgIF28BgAJ> 
> 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 
> <https://github.com/wagtail/wagtail/issues/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):
>
> [image: 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).
> On Sunday, 25 September 2022 at 12:12:21 UTC+1 ramez...@gmail.com wrote:
>
>> 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
>> [image: tabular_permisions.png]
>>
>> On Sunday, September 25, 2022 at 3:07:27 AM UTC+2 baido...@gmail.com 
>> wrote:
>>
>>> Thanks
>>>
>>> On Sat, Sep 24, 2022, 22:28 Danilov Maxim <ma...@wpsoft.at> wrote:
>>>
>>>> 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
>>>>
>>>>  
>>>>
>>>> *From:* django-d...@googlegroups.com [mailto:
>>>> django-d...@googlegroups.com] *On Behalf Of *Thibaud Colas
>>>> *Sent:* Saturday, September 24, 2022 9:25 AM
>>>> *To:* Django developers (Contributions to Django itself) <
>>>> django-d...@googlegroups.com>
>>>> *Subject:* Permissions don't get translated in admin interface
>>>>
>>>>  
>>>>
>>>> 👋 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 <https://code.djangoproject.com/ticket/1688> 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 
>>>> <https://explore.transifex.com/django/django/>, 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 
>>>> <https://docs.djangoproject.com/en/4.1/internals/contributing/localizing/> 
>>>> 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!
>>>>
>>>>  
>>>>
>>>>  
>>>>
>>>> -- 
>>>> 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
>>>>  
>>>> <https://groups.google.com/d/msgid/django-developers/8e14c59f-3331-401a-85a1-cbf27d49fe65n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> -- 
>>>> 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/000001d8d064%24f9d25dd0%24ed771970%24%40wpsoft.at
>>>>  
>>>> <https://groups.google.com/d/msgid/django-developers/000001d8d064%24f9d25dd0%24ed771970%24%40wpsoft.at?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>

-- 
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-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/2375709d-cf70-4720-aa22-d3e8817f74b4n%40googlegroups.com.

Reply via email to