{% set available_locales = app_locales|split('|') %}
{% if page is not empty %}
{% set current_locale = app.request.locale %}
{% set current_language_name = language_names[current_locale] | default(current_locale|upper) %}
<li class="d-inline-block d-none lg:d-flex">
<a href="#" class="hstack gap-1 text-none fw-medium" role="button" aria-haspopup="true" aria-expanded="false">
<i class="icon icon-1 unicon-earth-filled"></i>
<span>{{ current_language_name }}</span>
<span data-uc-drop-parent-icon=""></span>
</a>
<div class="p-2 bg-white dark:bg-tertiary-600 shadow-xs rounded w-150px"
data-uc-drop="mode: click; offset: 16; pos: bottom-center; boundary: !.uc-navbar-container; animation: uc-animation-slide-top-small; duration: 150;">
<ul class="nav-y gap-1 fw-medium rtl:items-end">
{% for locale in available_locales %}
{% set locale_path = getPathPageHasLanguages(page.id, locale) %}
{% set locale_name = language_names[locale] | default(locale|upper) %}
{% set has_path = locale_path and locale_path != "#" and locale_path is not empty %}
<li>
{% if has_path %}
<a href="{{ locale_path }}"{% if locale != current_locale %} hreflang="{{ locale }}"{% endif %}>
{{ locale_name }}
</a>
{% else %}
<span class="text-gray-400 dark:text-gray-500">{{ locale_name }}</span>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
</li>
{% endif %}