Question

I need to make an urlpattern different for each language, but following to the same view.

for example:

url(r'^category/(?P<slug>[\w-]+)/, 'news.views.category', name='category'), in english
url(r'^kategoria/(?P<slug>[\w-]+)/, 'news.views.category', name='category'), in polish

if you have EN set, "kategoria" won't work. Is it possible?

Was it helpful?

Solution

If you are using Django-version>=1.4. check internationalization for URL patterns. You can define translations for URLs using ugettext_lazy() or you can use i18n_patterns

OTHER TIPS

You should not create URL patterns like this .use i18n patterns in URL, in urls.py:

from django.translation import ugettext as _

Then make your URL patterns like this:

url(_(r'^category/(?P<slug>[\w-]+)/)) 

The translators will translate it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top