2011-06-16 01:29:10 +08:00
|
|
|
from django.conf import settings
|
2012-08-03 08:03:52 +08:00
|
|
|
from django.conf.urls import patterns, url
|
2011-06-16 01:29:10 +08:00
|
|
|
from django.core.urlresolvers import LocaleRegexURLResolver
|
|
|
|
|
|
|
|
def i18n_patterns(prefix, *args):
|
|
|
|
"""
|
|
|
|
Adds the language code prefix to every URL pattern within this
|
|
|
|
function. This may only be used in the root URLconf, not in an included
|
|
|
|
URLconf.
|
|
|
|
|
|
|
|
"""
|
|
|
|
pattern_list = patterns(prefix, *args)
|
|
|
|
if not settings.USE_I18N:
|
|
|
|
return pattern_list
|
|
|
|
return [LocaleRegexURLResolver(pattern_list)]
|
|
|
|
|
2005-11-04 12:59:46 +08:00
|
|
|
|
|
|
|
urlpatterns = patterns('',
|
2012-08-03 08:03:52 +08:00
|
|
|
url(r'^setlang/$', 'django.views.i18n.set_language', name='set_language'),
|
2005-11-04 12:59:46 +08:00
|
|
|
)
|