website/templates/language_selector.html
Alexander Borsuk 80153d7dee Do not escape urls where it is not needed
Signed-off-by: Alexander Borsuk <me@alex.bio>
2022-12-24 14:32:17 +01:00

27 lines
958 B
HTML

<span>
<script>
function onLanguageClick(langCode) {
window.localStorage.setItem('lang', langCode);
return true;
}
</script>
<!-- Hidden checkbox is used for pure CSS toggle menu. -->
{% if resource.translations | length > 1 %}
<input type="checkbox" id="lang-menu-trigger" class="lang-menu-trigger" />
{% endif %}
<label class="no-print" for="lang-menu-trigger">
 🌐 {{ lang | upper }}
</label>
<ul class="lang-menu no-print" role="navigation">
{% for translation in resource.translations | sort(attribute="lang") %}
{% if lang != translation.lang %}
<li class="lang-menu-item" role="menuitem">
<a class="lang-menu-link" onclick="return onLanguageClick('{{ translation.lang }}');" href="{{ translation.permalink | replace(from=config.base_url, to="") | safe }}">
{{ trans(key="language", lang=translation.lang) }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</span>