Add language middleware
This commit is contained in:
@@ -99,6 +99,7 @@ NOSE_ARGS = [
|
||||
]
|
||||
|
||||
MIDDLEWARE_CLASSES = [
|
||||
'sikweb.middleware.ForceDefaultLanguageMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class ForceDefaultLanguageMiddleware(object):
|
||||
"""
|
||||
Ignore Accept-Language HTTP headers
|
||||
|
||||
This will force the I18N machinery to always choose settings.LANGUAGE_CODE
|
||||
as the default initial language, unless another one is set via sessions or cookies
|
||||
|
||||
Should be installed *before* any middleware that checks request.META['HTTP_ACCEPT_LANGUAGE'],
|
||||
namely django.middleware.locale.LocaleMiddleware
|
||||
"""
|
||||
def process_request(self, request):
|
||||
if 'HTTP_ACCEPT_LANGUAGE' in request.META:
|
||||
del request.META['HTTP_ACCEPT_LANGUAGE']
|
||||
Reference in New Issue
Block a user