Website: Add i18n language detection (of browser language) and language
This commit is contained in:
parent
8f4970e16c
commit
5521f70289
@ -98,8 +98,9 @@ TEMPLATE_LOADERS = (
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
|
@ -47,7 +47,9 @@
|
||||
{% get_available_languages as languages %}
|
||||
{% for lang_code, lang_name in languages %}
|
||||
{% language lang_code %}
|
||||
<li {% if LANGUAGE_CODE == lang_code %}class="active"{% endif %}><a href="{{lang_code}}"><i class="icon-flag icon-white"></i> {{ lang_name }}</a></li>
|
||||
<li {% if LANGUAGE_CODE == lang_code %}class="active"{% endif %}>
|
||||
<a href="{% url home %}"><i class="icon-flag icon-white"></i> {{ lang_name }}</a>
|
||||
</li>
|
||||
{% endlanguage %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@ -125,4 +127,4 @@
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -7,7 +7,8 @@ from django.views.generic import TemplateView
|
||||
# from django.contrib import admin
|
||||
# admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = i18n_patterns('',
|
||||
url(r'^i18n/', include('django.conf.urls.i18n')),
|
||||
url(r'^$', TemplateView.as_view(template_name="home.html"), name='home',),
|
||||
url(r'^about/$', TemplateView.as_view(template_name="about.html"), name='about',),
|
||||
url(r'^about/features$', TemplateView.as_view(template_name="features.html"), name='features',),
|
||||
|
Loading…
Reference in New Issue
Block a user