Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#3832 closed (duplicate)

i18n of application names in admin

Reported by: omat@… Owned by: Adrian Holovaty
Component: contrib.admin Version: dev
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: no UI/UX: no

Description

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/adminapplist.py 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 by Simon G. <dev@…>, 18 years ago

Component: Contrib appsAdmin interface
Triage Stage: UnreviewedDesign decision needed

comment:2 by Malcolm Tredinnick, 18 years ago

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 by simonbun <simonbun@…>, 18 years ago

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 models.py file: _('myappname')
2) override the admin's index.html template and change out

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

with

<caption>{% trans app.name %}</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