divio/django-cms — pull request #1719 by piquadrat (2013-04-18 09:18:03+00:00)
Title: use our own get_language_from_request instead of Django's

Currently, django CMS will show the english version of a page even if english is not public, *if* the browser has english in its HTTP_ACCEPT_LANGUAGE header with a higher priority than any public languages.

Django's get_language_from_request has a global "_accepted" cache which is filled when ``get_language_from_request`` is called. This happens for the first time when a user visits the website in the ``LocaleMiddleware``. Django sees that there are translations for "en" available (translations in the sense of .po files) and adds "en" to ``_accepted``. This interferes
with our allowed frontend languages: translation.get_language_from_request
returns "en" even if it's not an available language.

What's also not clear to me is why ``MultilingualTestCase.test_frontend_lang`` still passed. It looks like the ``_accepted`` dictionary isn't filled for some reason during the tests.