{% set current_language    = languages[ current_language_code ] %}
{% set css_classes_flag    = ('wpml-ls-flag ' ~ backward_compatibility.css_classes_flag)|trim %}
{% set css_classes_native  = ('wpml-ls-native ' ~ backward_compatibility.css_classes_native)|trim %}
{% set css_classes_display = ('wpml-ls-display ' ~ backward_compatibility.css_classes_display)|trim %}
{% set css_classes_bracket = ('wpml-ls-bracket ' ~ backward_compatibility.css_classes_bracket)|trim %}

<div class="{{ css_classes }} wpml-ls-legacy-dropdown-click js-wpml-ls-legacy-dropdown-click"{% if backward_compatibility.css_id %} id="{{ backward_compatibility.css_id }}"{% endif %}>
	<ul>

		<li class="{{ current_language.css_classes }} wpml-ls-item-legacy-dropdown-click">

			<a href="#" class="{{ ('js-wpml-ls-item-toggle wpml-ls-item-toggle ' ~ current_language.backward_compatibility.css_classes_a)|trim }}">
				{%- if current_language.flag_url -%}
					<img class="{{ css_classes_flag }}" src="{{ current_language.flag_url }}" alt="{{ current_language_code }}" title="{{ current_language.flag_title }}">
				{%- endif -%}

				{%- if current_language.display_name or current_language.native_name -%}
					{%- set current_language_name = current_language.display_name|default(current_language.native_name) -%}
					<span class="{{ css_classes_native }}">{{- current_language_name -}}</span>
				{%- endif -%}
			</a>

			<ul class="js-wpml-ls-sub-menu wpml-ls-sub-menu">
				{% for language in languages if not language.is_current %}

					<li class="{{ language.css_classes }}">
						<a href="{{ language.url }}">
							{%- if language.flag_url -%}
								<img class="{{ css_classes_flag }}" src="{{ language.flag_url }}" alt="{{ language.code }}" title="{{ language.flag_title }}">
							{%- endif -%}

							{%- if language.native_name -%}
							<span class="{{ css_classes_native }}">{{ language.native_name }}</span>
							{%- endif -%}
							{%- if language.display_name -%}
								<span class="{{ css_classes_display }}">
									{%- if language.native_name -%}<span class="{{ css_classes_bracket }}"> (</span>{%- endif -%}
										{{- language.display_name -}}
									{%- if language.native_name -%}<span class="{{ css_classes_bracket }}">)</span>{%- endif -%}
								</span>
							{%- endif -%}
						</a>
					</li>

				{% endfor %}
			</ul>

		</li>

	</ul>
</div>