#34069: get_language_from_request should not fallback to settings.LANGUAGE_CODE
-------------------------------------+-------------------------------------
     Reporter:  sergioisidoro        |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:                       |                  Version:  4.1
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n                 |             Triage Stage:
  get_language_from_request          |  Unreviewed
  middleware                         |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by sergioisidoro:

Old description:

> I'm writing a middleware to fallback to a different language depending on
> the TLD of the domain of the HTTP_HOST
>
> However, I noticed that `get_language_from_request` falls back to the
> settings default language, which will almost always take precedence in
> this case.
>
> This is quite confusing, since `settings.LANGUAGE_CODE` is not "from the
> request", but from the application configuration, and it feels that the
> responsibility of falling back to the default language should lie in the
> Middleware, not in this function.

New description:

 I'm writing a middleware to fallback to a different language depending on
 the TLD of the domain of the HTTP_HOST

 However, I noticed that `get_language_from_request` falls back to the
 settings default language, which will almost always take precedence in
 this case.

 This is quite confusing, since `settings.LANGUAGE_CODE` is not "from the
 request", but from the application configuration, and it feels that the
 responsibility of falling back to the default language should lie in the
 Middleware, not in this function.

 Solution / Summary: `get_language_from_request` should return None, to
 communicate to the middleware that there was no language from request, and
 that the middleware should fallback to the default. Otherwise if the
 `get_language_from_request` returns "EN" we don't know if "EN" is actually
 a request preference, or because it came from the default
 `settings.LANGUAGE_CODE`

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34069#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701839851ec37-64bc926a-a56c-499d-92ef-1cd0220a2e91-000000%40eu-central-1.amazonses.com.

Reply via email to