#30272: get_language_from_path not respecting i18n_patterns prefix_default_language=False -------------------------------------+------------------------------------- Reporter: Stefan Wehrmeyer | Owner: nobody Type: Bug | Status: closed Component: | Version: 2.1 Internationalization | Severity: Normal | Resolution: wontfix Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Stefan Wehrmeyer): Sorry, some more details about the use case. I'm running a Django CMS instance with their URLs included via `i18n_patterns` and `prefix_default_language=False`. I want the URL path to determine what language to serve (and `LocaleMiddleware` set this language correctly!). The problem is that Django CMS relies on `get_language_from_request` ([https://github.com/divio/django- cms/blob/eeb1e4712b3866e243daf800c142e2199e4be9df/cms/views.py#L85 e.g. here]) to detect which language to serve without the additional logic that is included in `LocaleMiddleware` to special case `prefix_default_language=False`. Example URLs with default language "en": - `/de/ueber/` – `LocaleMiddleware` sets "de", `get_language_from_request` with `check_path=True` returns "de" - `/about/` – `LocaleMiddleware` sets "en", `get_language_from_request` with `check_path=True` returns whatever is in session, language cookie or HTTP `Accept-Language` header, but should return "en" like `LocaleMiddleware` This leads in turn to the wrong language being served. This could certainly be solved in Django CMS as well. But currently there are cases when `LocaleMiddleware` will set a different language on the request than is returned by `get_language_from_request` – which makes this public API inconsistent IMHO. Thanks for taking the time to look into this. I can try to provide a test case if this makes it clearer. -- Ticket URL: <https://code.djangoproject.com/ticket/30272#comment:4> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.6f0b8f81edb173f7931fb5560f69dfdc%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.