coding utf-8 from django conf urls defaults import from django conf im

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from django.conf import settings
from django.core.urlresolvers import RegexURLResolver
from django.utils import translation
def resolve_decorator(func):
def wrapper(*args, **kw):
output = func(*args, **kw)
locale = output[2].pop('locale', None)
if locale:
translation.activate(locale)
return output
return wrapper
RegexURLResolver.resolve = resolve_decorator(RegexURLResolver.resolve)
supported = dict(settings.LANGUAGES)
urlpatterns = patterns('',
(r'^(?P<locale>%s)/*' % ('|'.join(supported.keys())), include('urls')),
)