Created
December 11, 2013 11:49
-
-
Save breyten/7909059 to your computer and use it in GitHub Desktop.
Modify the locale middleware in python to not look at the HTTP_ACCEPT_LANGUAGE header (and just use the language specified in the settings or the user's preferences)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import re | |
from django.utils import translation | |
from django.middleware.locale import LocaleMiddleware | |
class LocaleNoHTTPAcceptMiddleware(LocaleMiddleware): | |
def process_request(self, request): | |
request.LANGUAGE_CODE = translation.get_language() | |
# Now just remember to do the following in your settings: | |
# MIDDLEWARE_CLASSES = [ | |
# ... | |
# 'django.middleware.locale.LocaleMiddleware', | |
# '<appname>.middleware.LocaleNoHTTPAcceptMiddleware', | |
# ... | |
# ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment