#7720 closed (fixed)
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 Salvetti | Owned by: | Ramiro Morales |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Keywords: | cookie fallback language sublanguage root language | |
Cc: | dsalvetti@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
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).
Attachments (3)
Change History (7)
by , 16 years ago
Attachment: | fallback_to_first_part_of_language_code_of_cookie.diff added |
---|
comment:1 by , 16 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 15 years ago
Attachment: | 7720-fallback-to-root-lang-when-lang-pref-stored-in-cookie.diff added |
---|
Patch with original fix by djoume plus tests
comment:2 by , 15 years ago
Keywords: | cookie fallback language sublanguage root language added |
---|---|
milestone: | → 1.2 |
Needs tests: | unset |
Owner: | changed from | to
Summary: | LocaleMiddleware doesn't fallback to the first part of the language code. → LocaleMiddleware doesn't fallback to the first part of the language code when it's received from the user's browser in a cookie |
by , 15 years ago
Attachment: | 7720-fallback-to-root-lang-when-lang-pref-stored-in-cookie.2.diff added |
---|
Better fix: Don't assume root language name has a length of two, RC2616 says it can be up to eight chars long
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Looks good to me. I think we need some tests? (Is there any tests to test that?)