{% set localizedRoutes = localized_page_routes() %}

<span {{ attributes|default('')|raw }}>
    {% for localizedRoute in localizedRoutes.routes %}
        {% if localizedRoute.locale == localizedRoutes.currentLocale %}
            <span lang="{{ localizedRoute.locale }}" aria-current="page">{{ localizedRoute.locale|upper }}</span>
        {% else %}
            <a
                href="{{ localizedRoute.path }}"
                lang="{{ localizedRoute.locale }}"
                hreflang="{{ localizedRoute.hreflang }}"
                aria-label="{{ localizedRoute.languageName }}"
            >{{ localizedRoute.locale|upper }}</a>
        {% endif %}

        {% if not loop.last %}
            <span aria-hidden="true">/</span>
        {% endif %}
    {% endfor %}
</span>
