From d604fa65ddad76100d9061d35b4129e6c6c5771d Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 18 Feb 2024 14:59:47 +0100 Subject: Create optional language switcher --- templates/header.html | 1 + templates/language_switcher.html | 11 +++++++++++ templates/nav.html | 9 +++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 templates/language_switcher.html (limited to 'templates') diff --git a/templates/header.html b/templates/header.html index f92e903..6e56025 100644 --- a/templates/header.html +++ b/templates/header.html @@ -1,4 +1,5 @@
+ {% include "language_switcher.html" %}

{{ config.title }}

diff --git a/templates/language_switcher.html b/templates/language_switcher.html new file mode 100644 index 0000000..b82ddfc --- /dev/null +++ b/templates/language_switcher.html @@ -0,0 +1,11 @@ +{% if config.extra.language_switcher %} + +{% endif %} diff --git a/templates/nav.html b/templates/nav.html index cd2d391..ac3f44e 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -7,10 +7,15 @@ {%- if config.extra.main_menu %} {%- for item in config.extra.main_menu %} {% set language_key = 'name_' ~ current_lang %} + {% if current_lang == config.default_language %} + {% set title = item | get(key=language_key, default=item.name) %} + {% else %} + {% set title = item[language_key] %} + {% endif %} {%- if item.url is matching("https?://") %} - {{ item[language_key] }} + {{ title }} {%- else %} - {{ item[language_key] }} + {{ title }} {%- endif %} {%- endfor %} {%- endif -%} -- cgit 1.4.1