Michel,
Thanks again, for your availability in helping me.
Actually, that was almost what I have been doing, except that I was not
working with '( option1 | option2 )' regex. I was adding one language each
line, but works the same.
Like this:
url(_(r'^planos/$'), WebSitePlanosView.as_view(),
name='WebSitePlanosView'),
url(r'^planos/$', WebSitePlanosView.as_view()),
url(r'^plans/$', WebSitePlanosView.as_view()),
The problem is when I have the 'include's:
url(r'^suporte/', include('WebSuporte.urls', )), #
pt_BR, es
url(r'^support/', include('WebSuporte.urls', )), #
en
url(_(r'^suporte/'), include('WebSuporte.urls')),
In this cases my tests showed that the 'translated' should come last, or
the reverse won't respect the user's language when choosing the url to show.
Of course this is a solution, but I was wondering if it has a DRY way of
doing this, since I haven't found on the docs, mainly because of the
maintenance when adding a language, for example, that would make changing
both translation files and all urls.py.
Thanks for you time and attention, if an new solution raises, it would be
great!
Felipe
On Friday, February 7, 2014 2:29:18 PM UTC-2, Felipe Mesquita de Oliveira
wrote:
>
> 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 [email protected].
To post to this group, send email to [email protected].
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/1964ef8e-bdeb-4181-b848-3152180463ab%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.