{% load i18n %}

<form class="lang_switcher" action="{% url 'set_language' %}" method="post" data-bind="attr:{id: formid}">
    <input type="hidden" name="csrfmiddlewaretoken" data-bind="value: $data.csrfToken" />
    <input name="next" type="hidden" value="{{ redirect_to }}">
    <select name="language" data-bind="
        select2Query: {
            select2Config: {value: value, dropdownCssClass: 'lang_switcher_dd', minimumResultsForSearch: -1}
        }, attr:{'data-label': $root.translations.pageLanguage}">
        {% get_current_language as LANGUAGE_CODE %}
        {% get_available_languages as LANGUAGES %}
        {% for CODE, NAME in LANGUAGES %}
        <option value="{{ CODE|lower }}" {% if CODE|lower == LANGUAGE_CODE|lower %}selected="selected" {% endif %}>
            {{ NAME }} ({{ CODE }})
        </option>
        {% endfor %}
    </select>
</form>