Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 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:

Description

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 www.example.com/LANG/app 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)

urllang.py (1.8 KB) - added by benoitcsirois 4 years ago.
The middleware i have been using.

Download all attachments as: .zip

Change History (3)

Changed 4 years ago by benoitcsirois

The middleware i have been using.

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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 4 years ago by jezdez

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)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.