Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Getting the language from the URL: locale_url
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joost Cassee  
View profile  
 More options May 30 2008, 10:13 am
From: Joost Cassee <cas...@gmail.com>
Date: Fri, 30 May 2008 16:13:00 +0200
Subject: Getting the language from the URL: locale_url
Hi all,

A followup to my previous message: I have made a Django application that
gets the language from the URL. It is located at:
http://www.cassee.org/trac/wiki/LocaleUrl

To enable, add locale_url.middleware.LocaleUrlMiddleware to settings.py
and add locale_url to the applications list to enable the template tags
and filters. Add the i18n context processor. Adding the request context
processor is also advised to give template tags access to the request.

The app support the following functionality:
* Paths like '/nl/admin/' are rewritten to '/admin/', so urls.py does
not have to be changed.
* Paths without locale are redirected to the default locale (from
settings.LANGUAGE_CODE) or a previous language discovery middleware.
* settings.LANGUAGE_INDEPENDENT_PATHS is a tuple of regular expressions
of paths that should not be redirected. Also MEDIA_URL is not redirected.
* urlresolvers.reverse is monkey patched to return paths with locale.
* 'locale_url' template tag to render a path in HTML (like the 'url'
tag, but with locale info): {% locale_url "nl" app.views.view arg=value
%}, or {% locale_url "de" %} for the current page in a different language.

Bugs:
* The 'reverse' patch does not take LANGUAGE_INDEPENDENT_PATHS into
account (will be fixed soon).
* Admin (in newforms-admin at least) does not use the 'url' tag, but its
own 'app_path' variable. This breaks login. Override 'admin/login.html'
and change the form action URL as follows:

<form action="/{{ LANGUAGE_CODE }}{{ app_path }}" method="post"
id="login-form">

I known this is all still a bit rough. Still, I hope some of you find it
useful. Comments and discussion on design and implementation are very
welcome.

Regards,

Joost


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Panos Laganakos  
View profile  
 More options May 30 2008, 10:37 am
From: "Panos Laganakos" <panos.lagana...@gmail.com>
Date: Fri, 30 May 2008 17:37:52 +0300
Local: Fri, May 30 2008 10:37 am
Subject: Re: Getting the language from the URL: locale_url
Ah, seems we're getting somewhere with this :)

I'll look into it, thanks for posting it.

--
Panos Laganakos

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Panos Laganakos  
View profile  
 More options Jun 11 2008, 7:49 am
From: "Panos Laganakos" <panos.lagana...@gmail.com>
Date: Wed, 11 Jun 2008 14:49:21 +0300
Local: Wed, Jun 11 2008 7:49 am
Subject: Re: Getting the language from the URL: locale_url
Maybe this should be moved on to the DM repository as it's closely
related to it?

Most people (if not all), who use DM, would want to use this app too.
Plus it'll get much closer testing there.

Any ideas how to resolve the `reverse` issue yet? :)

On Fri, May 30, 2008 at 5:37 PM, Panos Laganakos

--
Panos Laganakos

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joost Cassee  
View profile  
 More options Jun 11 2008, 8:08 am
From: Joost Cassee <jo...@cassee.net>
Date: Wed, 11 Jun 2008 14:08:02 +0200
Local: Wed, Jun 11 2008 8:08 am
Subject: Re: Getting the language from the URL: locale_url

On 11-06-08 13:49, Panos Laganakos wrote:

> Maybe this should be moved on to the DM repository as it's closely
> related to it?

I am now hosting is on Google Code:

http://django-localeurl.googlecode.com

> Most people (if not all), who use DM, would want to use this app too.
> Plus it'll get much closer testing there.

I agree that it is a good match. The idea of having the language on the
URL has also seen the most discussion on this list. On the other hand it
is definitely functionality that can stand on its own. I like having
small independent apps. You might call it the UNIX school of Django. :-)

It is not that I am adverse to having it in the same repo, it's just
that setting up a Google Code project is so easy that the overhead of
having it in its own place is negligible.

> Any ideas how to resolve the `reverse` issue yet? :)

That issue has been fixed. I now replace the reverse function on one of
my own if the middleware is installed.

The only problem left is the fact that the admin interface does not use
the standard Django standard of generating URLS using reverse and the
url tag. Maybe I should just special-case the admin?

Regards,

Joost

--
Joost Cassee
http://joost.cassee.net

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »