Friday, February 7, 2014

Translated URL's

Hi all,


I'm trying to work with translated URL's, but the behavior  I'm getting is not the one I expected.

Part of the code is below:

from django.utils.translation import ugettext_lazy as _

urlpatterns += patterns('',
             url(_(r'^help/$'), HelpView.as_view(), name='HelpView'),
             url(_(r'^new/'), include('News.urls')),  # two views inside this include: "/page-one/" and "page-two"
)


Imagining that I have English (en) and Spanish (es), the possible URL's would be:

/help/
/ayuda/
/news/
/news/page-one/
/news/page-two/
/noticias/
/noticias/pagina-um/
/noticias/pagina-dos/


Ok..
When I reverse "HelpView", if user language is set to 'en', I would get '/help/', and if user's language is 'es', I would get '/ayuda/'.
But, if the user with language set to 'es' access '/help/' (which is 'en'), I wanted the user to be able to see the page, but I'm getting Http-404 error.

Actually, even if the user (somehow) get to '/news/pagina-um', I wanted him to see the page (rendered using his/her language setting), and not Http404.

Thanks for any help, and if I was not clear, please let me know.

Regards,
Felipe
(Sp/Bra)





--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d6389b69-c8a4-483b-be17-df6c16b0803d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment