{# templates/admin/base_site.html #}
{% extends "admin/base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {{ site_title }}{% endblock %}

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header }}</a></h1>
{% endblock %}

{% block usertools %}
{{ block.super }}
<form method="post" action="{% url 'set_language' %}" style="display:inline-block; margin-left: 1rem;">
  {% csrf_token %}
  <input type="hidden" name="next" value="{{ request.get_full_path }}">
  <select name="language" onchange="this.form.submit();">
    {% get_current_language as LANGUAGE_CODE %}
    {% get_available_languages as LANGUAGES %}
    {% for code, name in LANGUAGES %}
      <option value="{{ code }}" {% if code == LANGUAGE_CODE %}selected{% endif %}>{{ name }}</option>
    {% endfor %}
  </select>
</form>
{% endblock %}
