Reputation: 2472
I am trying to set up a multi-language django site, I have added the languages I need in my settings file and translated everything in my django.po file. I added the locale middleware and language blocks to my urls and they display correctly when I navigate through them:
/es-mx/help --- displays in spanish
/en-us/help --- displays in english
Now I want to translate the urls, this is my urls.py:
from django.utils.translation import ugettext_lazy as _
urlpatterns += i18n_patterns('',
url(_(r'^help/'), include('help.urls')),
)
I want to have the following:
/es-mx/ayuda -- displays in spanish
/en-us/help --- displays in english
But I only get 404s when going to the spanish url. I have tried adding the following in my django.po file with no results:
msgid "r^help/"
msgstr "r^ayuda/"
msgid "help"
msgstr "ayuda"
What am I missing?
Upvotes: 0
Views: 620
Reputation: 33923
I think your msgid
and msgstr
are wrong here:
msgid "r^help/"
msgstr "r^ayuda/"
you've mistakenly included the r
in front, but this is not actually part of the string of the url pattern...
notice that in the url pattern it is r"^help/"
...the r
prefix tells Python this is a raw string and to ignore any escape chars, which is a useful thing when working with regular expressions
Everything else looks right to me, from my reading of the docs, so I think you just need to change them to:
msgid "^help/"
msgstr "^ayuda/"
Upvotes: 1