{% set type = journal2.settings.get(staticCall('Journal2Utils', 'getDevice') == 'desktop' ? 'language_display' : 'language_display_mobile', 'flag') %}
{% if languages | length > 1 %}
  <form action="{{ action }}" method="post" enctype="multipart/form-data">
    <div id="language" class="{{ journal2.settings.get('language_display', 'never') == 'full' ? 'full-text' : '' }}">
      <div class="btn-group">
        <button class="dropdown-toggle" type="button" data-hover="dropdown">
          <div>
            {% for language in languages %}
              {% if language.code == code %}
                {% if type == 'flag' %}
                  <img width="16" height="11" src="{{ staticCall('Journal2Utils', 'getLanguageFlag', [language]) }}" alt="{{ language.name }}">
                {% elseif type == 'text' %}
                  {{ language.name }}
                {% elseif type == 'full' %}
                  <img width="16" height="11" src="{{ staticCall('Journal2Utils', 'getLanguageFlag', [language]) }}" alt="{{ language.name }}">
                  <span class="language-text">{{ language.name }}</span>
                {% endif %}
              {% endif %}
            {% endfor %}
          </div>
        </button>
        <ul class="dropdown-menu">
          {% for language in languages %}
            <li>
              <a onclick="$(this).closest('form').find('input[name=\'code\']').val('{{ language.code }}'); $(this).closest('form').submit();">
                {% if type == 'flag' %}
                  <img width="16" height="11" src="{{ staticCall('Journal2Utils', 'getLanguageFlag', [language]) }}" alt="{{ language.name }}">
                {% elseif type == 'text' %}
                  {{ language.name }}
                {% elseif type == 'full' %}
                  <img width="16" height="11" src="{{ staticCall('Journal2Utils', 'getLanguageFlag', [language]) }}" alt="{{ language.name }}">
                  <span class="language-text">{{ language.name }}</span>
                {% endif %}
              </a>
            </li>
          {% endfor %}
        </ul>
      </div>
      <input type="hidden" name="code" value=""/>
      <input type="hidden" name="redirect" value="{{ redirect }}"/>
    </div>
  </form>
{% endif %}
