{% load i18n %}

<div class="mt-8 pt-6 border-t border-base-300">
    <h2 class="text-lg font-semibold text-center mb-4">
        {% translate "title.language-selector" %}
    </h2>

    {% get_current_language as LANGUAGE_CODE %}
    {% get_available_languages as LANGUAGES %}
    {% get_language_info_list for LANGUAGES as languages %}

    <form action="{% url 'set_language' %}" method="post" class="flex flex-wrap items-center justify-center gap-3">
        {% csrf_token %}
        <input name="next" type="hidden" value="{{ request.path }}">

        <label for="language" class="label">
            {% translate "language.selector.label" %}
        </label>

        <select name="language" id="language" class="select select-bordered">
            {% for language in languages %}
            <option value="{{ language.code }}" {% if language.code == LANGUAGE_CODE %}selected{% endif %}>
                {{ language.name_local }}
            </option>
            {% endfor %}
        </select>

        <button type="submit" class="btn btn-primary">
            {% translate "button.change" %}
        </button>
    </form>
</div>
