Skip to content

Commit

Permalink
Add language menu
Browse files Browse the repository at this point in the history
Closes #316.
  • Loading branch information
HacKanCuBa committed Apr 10, 2018
1 parent f1f9467 commit be49962
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
3 changes: 2 additions & 1 deletion eventol/eventol/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
url(r'^accounts/', include('allauth.urls')),
url(r'^captcha/', include('captcha.urls')),
url(r'^jsi18n/$', JavaScriptCatalog.as_view(),
{'domain': 'djangojs', 'packages': None}, name='javascript-catalog')
{'domain': 'djangojs', 'packages': None}, name='javascript-catalog'),
url(r'^i18n/', include('django.conf.urls.i18n')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Expand Down
6 changes: 6 additions & 0 deletions eventol/front/eventol/static/manager/less/eventol.less
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ a.accordion-toggle {
margin-bottom: 0 !important;
}

.transparent {
background-color: transparent;
border-color: transparent;
}


/* Container text */

.container-text {
Expand Down
34 changes: 33 additions & 1 deletion eventol/manager/templates/base-main.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,29 @@
</ul>
</li>
{% endif %}
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as languages %}
{% if languages %}
<!-- language dropdown start-->
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<span class="vertical-middle">
<i class="fas fa-language fa-2x"></i>
</span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
{% for lang_code, lang in languages %}
<li class="{% if lang_code == LANGUAGE_CODE %}active{% endif %}">
<button class="transparent" value="{{ lang_code }}" id="lang_{{ forloop.counter }}" onclick="change_lang(this.value)">
<i class="far fa-flag"></i> {{ lang|title }}
</button>
</li>
{% endfor %}
</ul>
</li>
<!-- language.dropdown end -->
{% endif %}
{% if not user.is_authenticated %}
<li class="dropdown">
<a href="#" data-target="#" class="dropdown-toggle"
Expand Down Expand Up @@ -244,7 +267,7 @@
<div class="container-fluid">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{% ifequal message.tags 'error' %}danger{% else %}{{ message.tags }}{% endifequal %} alert-dismissible text-center"
<div class="alert alert-{% ifequal message.tags 'error' %}danger{% else %}{{ message.tags }}{% endifequal %} alert-dismissible text-center"
role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
Expand Down Expand Up @@ -273,6 +296,15 @@
$.material.options.autofill = true;
$.material.init();
});
function change_lang(language_code) {
$.post(
"{% url 'set_language' %}",
{language: language_code, csrfmiddlewaretoken: "{% csrf_token %}"},
function(data, status, xhr) {
location.reload();
}
);
}
</script>
{% endblock %}
{% block other-script %}{% endblock %}
Expand Down

0 comments on commit be49962

Please sign in to comment.