This section describes how to install the localeurl application in your Django project.
Setup consists of installing the middleware and adding 'localeurl' to the installed applications list.
Add 'localeurl.middleware.LocaleURLMiddleware' to settings.MIDDLEWARE_CLASSES. It must come before 'django.middleware.common.CommonMiddleware' or settings.APPEND_SLASH will not work.
Add 'localeurl' to settings.INSTALLED_APPS. Because the application needs to replace the standard urlresolvers.reverse function, it is important to place it at the top of the list:
INSTALLED_APPS = (
'localeurl',
...
)
If you want to use the view, include the localeurl URLconf module in your project:
urlpatterns = patterns('',
...
(r'^localeurl/', include('localeurl.urls')),
...
)
Make sure settings.LANGUAGE_CODE or its root language is in settings.LANGUAGES. For example, if LANGUAGE_CODE == 'en-us' then LANGUAGES must contain either 'en-us' or 'en'. If you have not changed either option you do not have to do anything.
The application can be configured by editing the project’s settings.py file.
Example:
import re
LOCALE_INDEPENDENT_PATHS = (
re.compile('^/$'),
re.compile('^/games/'),
re.compile('^/ajax/'),
)