Django i18n: how to not translate the admin site?

前端 未结 4 1802
情书的邮戳
情书的邮戳 2020-12-30 03:13

I have an application in several languages but I would like to keepthe admin site always in english. What is the best way to do this?

Thanks in advance.

4条回答
  •  梦谈多话
    2020-12-30 03:31

    This is an interesting problem, and I couldn't find an easy strait forward answer so it looks like it will require an out of the box solution. Here are two ideas.

    1. This might be a crude way of doing it, but did you try deleting all of the language bundles under django.contrib.admin.locale except for en? I haven't tried it myself, but I think django will default back to english if that is the only locale left to display. It may just end up using the base django locale files if it can't find it but it is worth a try.

    2. The only other option that I could think of was to change the admin home page to a custom view where you manually set the django_language variable in the session or cookie to english and then redirect to the normal admin page.

    See these links for some ideas.

    http://code.djangoproject.com/browser/django/trunk/django/views/i18n.py

    http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/#the-set-language-redirect-view

提交回复
热议问题