{% load i18n %}
{# Display language selector as a dropdown rather than a form --> - see http://blog.oscarcp.com/?p=163#}
{# https://docs.djangoproject.com/en/dev/topics/i18n/translation/#the-set-language-redirect-view #}
{% if i18n_is_set %}
    <li class="dropdown">
      {% get_language_info for LANGUAGE_CODE as current %}
      {% get_available_languages as LANGUAGES %}
      {% get_language_info_list for LANGUAGES as languages %}
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-foo={{ current.code }}>{{ current.name_local|capfirst }} <span class="caret"></span></a>

      <ul class="dropdown-menu scrollable-dropdown-menu">
        {% for language in languages %}
        {% if language.code != current.code %}
        <li>
            <form name="setLang{{language.code}}" action="{% url 'set_language' %}" method="POST">
                {% csrf_token %}
                <input type="hidden" name="language" value="{{ language.code }}" />
                <a class="dab-update-lang" href="#" onclick="document.setLang{{ language.code }}.submit();return false;">{{ language.name_local|capfirst }}</a>
            </form>
        </li>
        {% endif %}
        {% endfor %}
      </ul>
    </li>
{% endif %}
