Django tip: Translating your application names (app_label)

This MUST be a common issue for international developers: We use some geeky English name for our application and afterwards find that the translated admin index looks a little silly in the eyes of our native speaking users. Apparently a patch has been accepted in the Django dev version, but it’s not yet in the trunk. Here’s what to do: In your applications’ __init__.py files put:

1
2
from django.utils.translation import gettext_noop
gettext_noop("AppName")

When your run manage.py makemessages -a there will be entries for these. Make sure to remove lines saying #, fuzzy. Now all you have to do is to customize the default admin template called index.html so it will actually do the translation of the application names.

18
        <caption>{% trans app.name %}</caption>
This entry was posted in Django and tagged , , , . Bookmark the permalink.

2 Responses to Django tip: Translating your application names (app_label)

  1. Vlada Macek says:

    Thanks. I’d be glad to know how this applies to django-1.0, since now there is no make-messages.py to patch.

    And non-english users would welcome application names to be translated. Until now I haven’t found an easy way to do it.

  2. benjamin says:

    Sorry about the late reply. The patch has been approved, so now you just have to do the replacement in your admin template… that is: Replace the ‘blocktrans’ with a simple ‘trans’ and run ./manage.py makemessages -l (you language code) -a and you should see your application translations in the .po files given that you’ve also applied the dummy translation in __init__.py

    Hope this helps.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">