mirror of
https://github.com/YunoHost/doc.git
synced 2024-09-03 20:06:26 +02:00
31 lines
1.4 KiB
Twig
31 lines
1.4 KiB
Twig
<ul class="langswitcher">
|
|
{% set display_format = display_format ?? config.get('plugins.langswitcher.language_display', 'long') %}
|
|
{% for language in langswitcher.languages %}
|
|
|
|
{% set show_language = true %}
|
|
{% if language == langswitcher.current %}
|
|
{% set lang_url = page.url %}
|
|
{% set active_class = ' active' %}
|
|
{% else %}
|
|
{% set base_lang_url = base_url_simple ~ grav.language.getLanguageURLPrefix(language) %}
|
|
{% set lang_url = base_lang_url ~ langswitcher.page_route ~ page.urlExtension %}
|
|
{% set untranslated_pages_behavior = grav.config.plugins.langswitcher.untranslated_pages_behavior %}
|
|
{% if untranslated_pages_behavior != 'none' %}
|
|
{% set translated_page = langswitcher.translated_pages[language] %}
|
|
{% if (not translated_page) or (not translated_page.published) %}
|
|
{% if untranslated_pages_behavior == 'redirect' %}
|
|
{% set lang_url = base_lang_url ~ '/' %}
|
|
{% elseif untranslated_pages_behavior == 'hide' %}
|
|
{% set show_language = false %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% set active_class = '' %}
|
|
{% endif %}
|
|
|
|
{% if show_language %}
|
|
<li><a href="{{ lang_url ~ uri.params }}" class="external{{ active_class }}">{% include 'partials/langswitcher-' ~ display_format ~ '.html.twig' %}</a></li>
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
</ul>
|