@register.function
def locale_url(url):
 prefixer = urlresolvers.get_url_prefix()
 script = prefixer.request.META['SCRIPT_NAME']
 parts = [script, prefixer.locale, url.lstrip('/')]
 return '/'.join(parts)

@ register . function def locale_url ( url ) : prefixer = urlresolvers . get_url_prefix ( ) script = prefixer . request . META [ 'SCRIPT_NAME' ] parts = [ script , prefixer . locale , url . lstrip ( '/' ) ] return '/' . join ( parts )
take a url and give it the locale prefix .