Hi all,

About two years ago atlithorn posted some code to get the language for
a page from the URL. I have extended it and made it into a Django
application. Basically, it allows you to have URLs like 'http://
www.example.com/nl/about/". It is located at:

http://www.cassee.org/trac/wiki/LocaleUrl

That webpage also has complete docs. I am looking for comments on two
coding decision I made.

1) Monkey patching urlresolvers.reverse

I wanted to be able to use existing applications without having to
change their urls.py module. So the middleware strips off the language
prefix before handing it to the URL resolver. However, this means that
the urlresolvers.reverse function (and the url template tag) will not
return the correct URL. To solve this I let my application monkey
patch (replace) the urlresolvers.reverse function. Is there a better
way?

2) Forcing explicit re.comple('/path/') entries in
LOCALE_INDEPENDENT_PATHS

This settings variable is a tuple holding a list of paths that are not
language dependent. They are regular expressions and because they will
be used often they should not be compiled at every request. Because
the settings variables should not be changed (even at compile time, I
guess) I am now forcing the user to specify them explicitly as regular
expression objects. This looks a bit ugly in settings.py. (See the
example on the webpage.) Is there a better way?


The application currently only works for language specification on the
URL path, not for example the hostname (for example: 
http://fr.example/com/about/).
I might add this functionality if anyone asks.

I hope this is useful. Any comments, bug, discussion, etc. are very
welcome.


Regards,

Joost
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to