﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20125	get_language_from_request() - inconsistent use of fallback language	Max Arnold	nobody	"To set language code django.utils.translation.trans_real.get_language_from_request() consults four places in the following order:

1. url - get_language_from_path()
2. session - request.session.get('django_language', None)
3. cookie - request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME)
4. accept-language header - request.META.get('HTTP_ACCEPT_LANGUAGE', '')

Its docsting says:

    Analyzes the request to find what language the user wants the system to
    show. Only languages listed in settings.LANGUAGES are taken into account.
    **If the user requests a sublanguage where we have a main language, we send
    out the main language.**

(1) and (2) do not use get_supported_language_variant() function (which uses available main language when there is no sublanguage), making it impossible to always have full locale in url or session. Consider this use-case:

I want to build a site which will be available in several countries, and some of them have more than one official language. To do that, I allocate several url prefixes (locales) to always contain both language and country:

* /fr-ca/
* /en-ca/
* /en-us/
* /en-gb/

Using this scheme there is no need to have separate country selector in the url, and I can have only generic translations like 'en' and 'fr' with the possibility to add specific ones like 'en-gb'.

Is it worth to unify fallback language handling to allow full locale in url and session? There is also two recently closed related tickets: #19811 and #19763

Also this logic is not very easy to override - I can subclass LocaleMiddleware.process_request(), but get_language_from_request() is still monolithic. I think it is better to move accept-language normalization to separate function."	Cleanup/optimization	closed	Internationalization	1.5	Normal	fixed			Accepted	0	0	0	0	0	0
