Wednesday, June 27, 2012

Translated urls and accept-language header

Hello,

I've setup translated urls for some languages. The default language
for django has been set to en-US.

If you request a page /registration/ with nl-NL as Accept-Language
header, I get a 404.
I wasn't expecting such behaviour. Rather I was hoping I would be
redirected to /registratie/ ,the tranlated url that corresponds my
Accept-Language header.
Ofcourse /registratie/ with the nl-Nl Accept-Language header, works
fine and gives me the expected 200.

I'm guessing this is just as normal as it can get ?

Isn't there a chance a user might get link from some website and
the link is build for the English language, but the user in question
has a different supported language setting, Accept-Language header ?
In such a case he would be presented with a 404.
He should be presented with or the English (default) content or
or be redirected to the correct url for his language if supported.

Also what happens if a user has a not supported language setting ?
Will the django default LANGUAGE_CODE be used, en-US in my case ?

Is there a way to work around this or handle it in a different better way ?

an extract from my urls.py file, shows how I've setup translated urls:

url(_(r'^step1/$'), AccountTypeSelectionView.as_view(), name="registration_step1"),

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment