Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#17720 closed Bug (fixed)

LocaleMiddleware inspects language from URL path in a backwards incompatible way

Reported by: Anssi Kääriäinen Owned by: Jannis Leidel
Component: Internationalization Version: 1.4-beta-1
Severity: Release blocker Keywords:
Cc: Anssi Kääriäinen Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


As reported by Ryan Kaskel in this django-dev thread, the LocaleMiddleware inspects the user's language from the URL path in a backwards incompatible way.

Kaskel had /sl/ as a prefix for his URL path, and due to that Slovak was activated as the language to use. He did not use the new i18n_patterns method in his patterns.

The relevant commit is this: r16405

There is this warning added to the docs:

    Ensure that you don't have non-prefixed URL patterns that might collide 
    with an automatically-added language prefix. 

An user doesn't have much chance to dodge this issue: suggesting change of his existing URLs doesn't really fly.

I think the only sane fix is to detect if the user is using i18n_patterns in his root If he isn't, no language introspection should be done based on the URL path. I have attached a patch with tests for this. My reading of the docs suggests no changes are needed there.

I do think this is backwards incompatible and should be fixed in one way or another before 1.4. Marking this as Release Blocker due to this not really being my ticket, but a confirmation of Kaskel's findings.

Attachments (1)

17720.diff (5.7 KB) - added by Anssi Kääriäinen 8 years ago.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by Anssi Kääriäinen

Attachment: 17720.diff added

comment:1 Changed 8 years ago by Jannis Leidel

Owner: changed from nobody to Jannis Leidel
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

In [17547]:

Fixed #17720 -- Stopped the LocaleMiddleware from overeagerly using the request path for language activation if it's actually not wanted. Thanks to Anssi Kääriäinen for the initial patch.

comment:3 Changed 8 years ago by Ryan Kaskel

I've opened a ticket for a docs change related to this patch: #17723.

Note: See TracTickets for help on using tickets.
Back to Top