I have a django 1.6 site with i18n working. I can change the frontend language with a select box in the top of the template, but I don't know if there is a django app or trick to change the admin language, because it seems to store somewhere in session variable, and it keeps the first language I have used in the frontend.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can create /en/admin
, /fr/admin/
and so on using i18n_patterns
:
urlpatterns += i18n_patterns(
url(r'^admin/', include(admin.site.urls)),
)
(For Django <= 1.7, you must specify a prefix, use i18n_patterns('', ... )
)
回答2:
In your settings.py just add 'django.middleware.locale.LocaleMiddleware'
to your MIDDLEWARE_CLASSES
setting, making sure it appears after 'django.contrib.sessions.middleware.SessionMiddleware'
.