Skip to content

Commit

Permalink
do not try to detect browser language preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Feb 17, 2012
1 parent 4768cca commit 950a9f0
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions ckan/config/middleware.py
Expand Up @@ -54,12 +54,8 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
# Routing/Session/Cache Middleware
app = RoutesMiddleware(app, config['routes.map'])
app = SessionMiddleware(app, config)
#app = CacheMiddleware(app, config)
# NOTE: I18nMiddleware should not be cached as can create
# redirects based on browser language settings.
# We need to take the language settings into accout. For now
# disable the cacheing.
app = I18nMiddleware(app, config)
app = CacheMiddleware(app, config)

# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
#app = QueueLogMiddleware(app)
Expand Down Expand Up @@ -153,24 +149,6 @@ def __call__(self, environ, start_response):
else:
environ['PATH_INFO'] = '/'
else:
# See if we have a language the browser requests. If this is
# not the site default language then redirect to that
# language eg for french -> /fr/....
languages = environ.get('HTTP_ACCEPT_LANGUAGE', 'en')
languages = languages.replace('-', '_')
languages = languages.split(';')[0].split(',')
language = negotiate_locale(languages, self.local_list)
# if this is not the default locale of the site then we will
# redirect to the url using that language here.
if language != self.default_locale:
root = environ['SCRIPT_NAME']
url = environ['PATH_INFO']
url = url[len(root):]
url = '/%s%s%s' % (root, language, url)
headers = []
headers.append(('Location', url))
start_response('302 Found', headers)
return []
# use default language from config
environ['CKAN_LANG'] = self.default_locale
environ['CKAN_LANG_IS_DEFAULT'] = True
Expand Down

0 comments on commit 950a9f0

Please sign in to comment.