我有两种语言,并且我还在设置文件中设置了两种语言
LANGUAGES = (
('bn', _('Bengali')),
('en', _('English')),
)
LANGUAGE_CODE = 'bn'
中间件是
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
我还像波纹管一样在样式中包含了网址
urlpatterns += i18n_patterns(
......................
.................
)
对于默认语言 bn ,我已经在首页视图中添加了一行
request.session[translation.LANGUAGE_SESSION_KEY] = settings.LANGUAGE_CODE # LANGUAGE_CODE is **bn**