0👍
I don’t really like the idea of translating the URLs, but try something like this:
en/django.po:
msgid "^contact/"
msgstr "^en/contact/"
msgid "^wrong_lang/(?P<url_part>.+)"
msgstr "^ru/(?P<url_part>.+)"
urls.py:
url(_(r'^contact/'), include('contact.urls')), # matches "en/contact/" URL
url(_(r'^wrong_lang/(?P<url_part>.+)', redirect_to_current_lang), # matches "ru/..." URLs
views.py:
def redirect_to_current_lang(request, url_part):
return HttpResponseRedirect(_('^%s' % url_part))
Source:stackexchange.com