{% load i18n %}
<li class="dropdown">{% get_current_language as LANGUAGE_CODE %}{% get_available_languages as LANGUAGES %}{% get_language_info_list for LANGUAGES as languages %}
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ LANGUAGE_CODE }}<span class="caret"></span></a>
  <ul class="dropdown-menu">
    {% for language in languages %}
      <form action="{% url 'set_language' %}" method="post">{% csrf_token %}
        <input name="next" type="hidden" value="{{ redirect_to }}">
        <input name="language" type="hidden" value="{{ language.code }}">
        <button class="list-group-item list-group-item-action {% if language.code == LANGUAGE_CODE %}active{% endif %}" onclick="this.form.submit()">{{ language.code }}</button>
      </form>
    {% endfor %}
  </ul>
</li>
