Hi! I have tried to implement the internationalization system, but when selecting any of the 3 languages, it does not change the language for me. The selector after choosing the language takes me to a 404.
Error:
Page not found (404)
Request Method: | POST |
---|---|
Request URL: | http://localhost:8000/i18n/setlang/ |
Where is this url? What is this?
Settings.py
'django.middleware.locale.LocaleMiddleware', #Between session and common
LANGUAGE_CODE = 'en-us'
ttext = lambda s: s
LANGUAGES = (
('en', '{}/{}'.format(ugettext('EN'), 'English')),
('es', '{}/{}'.format(ugettext('ES'), 'Castellano')),
('eu', '{}/{}'.format(ugettext('EU'), 'Euskara')), #Basque language
)
TIME_ZONE = 'Europe/Madrid'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = (
os.path.join(BASE_DIR, "locale"),
)
Templates:
For example: {% trans ‘Restaurants’ %}
Language selector:
<form action="/i18n/setlang/" method="post">{% csrf_token %}
<input name="next" type="hidden" value="/" />
<select class="form-select" name="language">
{% for lang in LANGUAGES %}
<option value="{{ lang.0 }}">{{ lang.1 }}</option>
{% endfor %}
</select>
<input class="form-control" type="submit" value="Go" />
</form>
FIles:
Thanks!