Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#3832 closed (duplicate)

i18n of application names in admin

Reported by: omat@… Owned by: Adrian Holovaty
Component: contrib.admin Version: master
Severity: Keywords: admin i18n
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


This may be trivial, but, the admin application does not allow internationalization of the application names, it always uses the name in the INSTALLED_APPS setting.

If the line 21 of contrib/admin/templatetags/ is changed to:

app_label = _(app_models[0]._meta.app_label)

users will have control on the application name displayed in the admin application by i18n.

Change History (3)

comment:1 Changed 10 years ago by Simon G. <dev@…>

Component: Contrib appsAdmin interface
Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 10 years ago by Malcolm Tredinnick

Resolution: duplicate
Status: newclosed

This has come up before (#1668). The part you identify (doing the string exchange) is not the difficult part of this problem. The hard part is how to extract the application names in the first place. Somebody would need to modify the gettext extraction program to work out the application names. For a number of practical and security reasons, gettext should generally never run any code in the application, so you can't just import the modules and use Python introspection, unfortunately. You also can't expect everybody to have to write their module names out by hand: having an arbitrary technical phrase such as the module name translated isn't important enough to require that to be done by default.

I suspect there are solutions to this problem (maybe using the Python compile function and bytecode inspection), but it's not a trivial fix.

I'm going to close this as a dupe of #1668, but I wanted to explain what the real problem that has to be solved here is.

By the way, if you want translation of specific model names to happen, write something like

    class Meta:
        verbose_name = _("SuperWidget")
        verbose_name_plural = _("SuperWidgets")

in your code.

comment:3 Changed 10 years ago by simonbun <simonbun@…>

For what it's worth, there's a trivial workaround for this problem.

1) put your app name with gettext_lazy call in your model file. I just put it at the top of my file: _('myappname')
2) override the admin's index.html template and change out

<caption>{% blocktrans with as name %}{{ name }}{% endblocktrans %}</caption>


<caption>{% trans %}</caption>

in the app_list loop.

Hackish & not so elegant, but it does work.

Note: See TracTickets for help on using tickets.
Back to Top