Well as far I can test, Django i18n does supports fall-back 'xx-YY' to 'xx' then to default ('en' in my case) but only for 'Accept-Language' user agent header. It does not do same for URL language switch.
Here is the solution I could come up with:
from django.views.generic import RedirectView from django.conf import settings ... urlpatterns += patterns('', url(r'^(?P<lang>[a-z]{2})-[A-Za-z]{2}/(?P<path>.*)$', RedirectView.as_view(url='/%(lang)s/%(path)s',query_string=True)), url(r'^[a-z]{2}/(?P<path>.*)$', RedirectView.as_view(url='/{}/%(path)s'.format(settings.LANGUAGE_CODE),query_string=True)), ) - Any
xx-YYnot handled by i18n pattern redirected toxx - Any
xxnot handled by i18n pattern redirected to default language set usingLANGUAGE_CODE.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a14b0173-f665-401c-a665-e25ef9ddf976%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment