这是我的设置
LANGUAGES = (
('zh_CN', u'简体中文'),
('en-us', u'English'),
)
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# "django.middleware.cache.CacheMiddleware",
"django.middleware.transaction.TransactionMiddleware",
)
这是一些打印
('django_language', '')
('COOKIES', '')
('ACCEPT_LANGUAGE', 'zh_CN')
('LANGUAGE_CODE', 'en-us')
我的django版本为1.5.4
如果我设置
request.session['django_language'] = 'zh_CN'
下次我会得到翻译。怎么了?