From e933a44125d00df57eb41ceaa28c52c1feb56e23 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Fri, 2 Oct 2020 21:05:35 +0200 Subject: [PATCH] Add basic support for multilingual site Add language switcher on the top right of the site Switches taxonomies, article paths, home, etc. Every language is independent --- templates/index_macros.html | 44 +++++++++++++++++++++++++++++++++++-- templates/post_macros.html | 6 ++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/templates/index_macros.html b/templates/index_macros.html index 7e7e938..bd90f75 100644 --- a/templates/index_macros.html +++ b/templates/index_macros.html @@ -58,7 +58,11 @@
{% endif %} + + {% if config.languages %} + {% if config.default_language is not matching(lang) %} + {% set lang_url = current_url | replace(from=config.base_url ~ "/" ~ lang, to=config.base_url) %} + + {% endif %} + {% for available_lang in config.languages %} + {% set lang_code = available_lang.code %} + {% if lang_code is not matching(lang) %} + + {% if lang is matching(config.default_language) %} + {% set lang_url = current_url | replace(from=config.base_url ~ "/", to=config.base_url ~ "/" ~ lang_code ~ "/") %} + {% else %} + {% set lang_url = current_url | replace(from=config.base_url ~ "/" ~ lang, to=config.base_url ~ "/" ~ lang_code) %} + {% endif %} + + {% endif %} + {% endfor %} + {% endif %} +
diff --git a/templates/post_macros.html b/templates/post_macros.html index c057f83..b460bf1 100644 --- a/templates/post_macros.html +++ b/templates/post_macros.html @@ -93,7 +93,7 @@ {% if page.taxonomies.authors %} by {% for author in page.taxonomies.authors %} - + {{ author }} {% if page.taxonomies.authors | length > 1 %} @@ -113,7 +113,7 @@ and {% macro post_footer_categories(page) %} {% if page.taxonomies.categories %} {% set category = page.taxonomies.categories[0] %} -in +in {{ category }} @@ -126,7 +126,7 @@ in {% if page.taxonomies.tags %} and tagged {% for tag in page.taxonomies.tags %} - + {{ tag }} {% if page.taxonomies.tags | length > 1 %}