Reputation: 21
I am trying to translate a django app using the built in i18n. I have already marked the text to be translated and created and compiled the language files (.po/.mo
) according to the tutorial and with out errors. I've also changed the USE_I18N
to true in the settings file and added the following line into the urls.py as the tutorial instructed:
(r'^i18n/', include('django.conf.urls.i18n')),
I also defined a list of allowed languages in the settings.py, as instructed by the tutorial.
then i created a new page html template and copied in the code the tutorial gave for a language select page:
<form action="/i18n/setlang/" method="post"> {% csrf_token %} <input name="next" type="hidden" value="{{ redirect_to }}" /> <select name="language"> {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} <option value="{{ language.code }}">{{ language.name_local }} ({{ language.code }})</option> {% endfor %} </select> <input type="submit" value="Go" /> </form>
that page works perfectly too, but when i click on "Go", it tells me there was an error loading the page:
Failed to load resource:http://localhost:8000/i18n/setlang/
the server responded with a status of 404 (NOT FOUND)
I tried changing the redirect by replacing the variable with the link, but that gave me the same result. I tried changing the form action path and the urls.py in case there was some double naming, which gave me the same error.
I have been reading through the tutorial and the readmes, as well as some of the i18n files and can't seem to find a reason for it not to work, and i would really appreciate an answer. thankyou
Upvotes: 2
Views: 2244
Reputation: 558
Are you sure you used the correct urls.py, i.e. the one in your project root, and not in a subdirectory?
What happens if you change it to:
from django.http import HttpResponse
...
(r'^i18n/', lambda x: HttpResponse("Test")),
Can you go to http://localhost:8000/i18n/
after that?
Upvotes: 2