Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#13450 closed (wontfix)

Can django's i18n internationalization middleware offer language selection by URL?

Reported by: benoitcsirois Owned by: nobody
Component: Internationalization Version: 1.1
Severity: Keywords: i18n internationalization seo languages urls
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Django's current internationalization framework allows only the project's default language to be indexed by search engines, because a single URL is only indexed in one language in the search engine.

Would it be possible to implement a type of URL handling in django's internationalization framework?

I have been using something similar, which someone published (forget where I found it, see attached file for middleware), but it breaks django's reverse url lookup, unless I specify urls with a (?P<lang>(\w\w)) at the beginning... thus resulting in a useless "lang" parameter passed-on to views.

Can a simpler, more integrated solution be implemented?

Attachments (1) (1.8 KB) - added by benoitcsirois 8 years ago.
The middleware i have been using.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by benoitcsirois

Attachment: added

The middleware i have been using.

comment:1 Changed 8 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

I'm fairly certain what you describe can be achieved by setting request.urlconf in the middleware.

As for adding this to Django; my inclination is that this probably isn't suitable for core. It strikes me as a design pattern that requires a lot more infrastructure than just a middleware - it would also require language-sensitive models etc, which is the domain of external projects like django-rosetta.

However, this isn't a particularly strongly held position; if you want to make your case for the inclusion of a feature like this, feel free to advocate for it on django-developers (preferably after the 1.2 release is out the door, so we can give it the proper attention).

comment:2 Changed 8 years ago by Jannis Leidel

FWIW, you can easily add this feature to your site with the third party app django-localeurl.

(Btw, this is a little bit of a duplicate of #9333)

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