在我看来,我设置这样的语言。
if request.LANGUAGE_CODE == 'en':
translation.activate('en')
else:
translation.activate('pt')
当去 url /pt/foo/faa/
有用。
但是语言没有设置。一旦我点击了一个链接,比如 about 链接,url 就会变成 /en/about/../ 而不是 /pt/about../,就像我认为的那样。
这是我的网址:
from django.conf.urls import patterns, include, url
from django.conf.urls.i18n import i18n_patterns
urlpatterns = i18n_patterns('',
(r'^i18n/', include('django.conf.urls.i18n')),
(r'^news/', include('news.urls')),
....
设置.py
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = ()
我理解错了吗?