Я сейчас работаю над сайтом. Я начал работать над его интернационализацией.
Код для меню выбора языка:
<form action="/i18n/setlang/" method="post">
<select name="language">
{% for lang in LANGUAGES %}
<option value="{{ lang.0 }}">{{ lang.1 }}</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>
{{ LANGUAGE_CODE }}
Но, похоже, это не работает. Он просто перенаправляет на ту же страницу
Я добавил
(r'^i18n/', include('django.conf.urls.i18n'))
до urls.py
;
'django.middleware.locale.LocaleMiddleware'
до
MIDDLEWARE_CLASSES
в settings.py
'django.core.context_processors.i18n',
до
TEMPLATE_CONTEXT_PROCESSORS в settings.py
Должен ли я что-нибудь импортировать?
UPDATE
Когда я добавлю
LANGUAGES = (
('es', _('Spanish')),
('en-US', _('AmericanEnglish')),
)
в settings.py я получаю
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Иначе хотя бы сайт работает