2011-06-16 01:29:10 +08:00
|
|
|
from django.conf import settings
|
2011-09-12 06:36:16 +08:00
|
|
|
from django.conf.urls import patterns
|
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('',
|
|
|
|
(r'^setlang/$', 'django.views.i18n.set_language'),
|
|
|
|
)
|