Reputation: 3038
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?
Upvotes: 0
Views: 205
Reputation: 1
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.
Upvotes: 0
Reputation: 1196
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
Upvotes: 1