<form action="{% if languages_action %}{{ languages_action }}{% else %}{% url 'set_language' %}{% endif %}" method="post" class="flex w-full">
    {% csrf_token %}

    <input name="next" type="hidden" value="{{ redirect_to }}">
    <input name="language" type="hidden" value="{{ language.code }}">

    <button type="submit" class="block cursor-pointer flex flex-row grow items-center gap-1 mx-1 px-3 py-2 rounded-default text-left hover:bg-base-100 hover:text-base-700 dark:hover:bg-base-700 dark:hover:text-base-200 {% if language.code == LANGUAGE_CODE %}text-primary-600 dark:text-primary-500 dark:hover:text-primary-500! hover:text-primary-600!{% endif %}">
        {% for language_key, language_flag in language_flags.items %}
            {% if language_key == language.code %}
                <span class="mr-1">{{ language_flag }}</span>
            {% endif %}
        {% endfor %}

        {{ language.name_local }} <span class="ml-auto uppercase font-semibold text-xs text-subtle">{{ language.code }}</span>
    </button>
</form>
