{# {} is the default value. #}
{% if theme_language_select and theme_language_select != {} %}
{% if not theme_language_url %}
{{ warning('html_theme_options.language_url is not set. Please set it to enable language switcher.') }}
{% else %}
{% for code, label in theme_language_select.items() %}
{#
`pathto('/' + pagename)` - pathto() needs absolute path, but pagename returns string without "/"
But `pathto('/' + pagename)` produces double slashes in the URL (e.g. //index.html). So we need to strip leading slash with `lstrip('/')`.
#}
{% set pagename_url = pathto('/' + pagename).lstrip('/') %}
{%
set language_url = theme_language_url
.replace("$LANGUAGE", code)
.replace("$PAGE", pagename_url)
%}