LocaleMiddleware doesn't fallback to the first part of the language code when it's received from the user's browser in a cookie
|Reported by:||djoume||Owned by:||ramiro|
|Severity:||Keywords:||cookie fallback language sublanguage root language|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a project where the language cookie is set by another system (under the same domain).
This system set the LANGUAGE_COOKIE to 'fr-ca' or 'en-us'.
I have in my settings file:
LANGUAGES = ( ('en', ugettext('English')), ('fr', ugettext('French')), )
According to the documentation, this should restrict languages that are available for automatic selection to French and English (and any sublanguage, like fr-ca or en-us).
This is true when the language is set in the HTTP Header (ie fr-ca matches fr) but not when the language is set in the LANGUAGE_COOKIE by another system.
The attached patch is a tentative to fix this (it works for me).
Change History (7)
Changed 7 years ago by djoume
comment:1 Changed 7 years ago by serialx
- Needs documentation unset
- Needs tests set
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
Changed 5 years ago by ramiro
comment:2 Changed 5 years ago by ramiro
- Keywords cookie fallback language sublanguage root language added
- milestone set to 1.2
- Needs tests unset
- Owner changed from nobody to ramiro
- Summary changed from LocaleMiddleware doesn't fallback to the first part of the language code. to LocaleMiddleware doesn't fallback to the first part of the language code when it's received from the user's browser in a cookie