- {% set tags = get_taxonomy(kind="tags") %}
+ {% set tags = get_taxonomy(kind="tags", lang=lang) %}
{% for post in tags.items %}
#{{ post.name }}
{% endfor %}
diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html
index 0f640a2..a8ca536 100644
--- a/templates/taxonomy_single.html
+++ b/templates/taxonomy_single.html
@@ -22,7 +22,7 @@
{% else %}
- No posts yet
+ {{ trans(key="no_posts", lang=lang) }}
{% endfor %}
--
cgit 1.4.1
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
---
config.toml | 14 ++++++++++----
templates/header.html | 1 +
templates/language_switcher.html | 11 +++++++++++
templates/nav.html | 9 +++++++--
4 files changed, 29 insertions(+), 6 deletions(-)
create mode 100644 templates/language_switcher.html
(limited to 'templates')
diff --git a/config.toml b/config.toml
index 5a54517..92637f3 100644
--- a/config.toml
+++ b/config.toml
@@ -44,23 +44,29 @@ highlight_code = true
[extra]
date_format="%d %b, %Y"
webserver_sends_csp_headers=true
+language_switcher=true
+
+translations = [
+ { code="en", name="English" },
+ { code="de", name="Deutsch" },
+]
[[extra.main_menu]]
-name_en = "Home"
+name = "Home"
name_de = "Startseite"
url = "/"
[[extra.main_menu]]
-name_en = "Bear"
+name = "Bear"
name_de = "Bear"
url = "@/bear.md"
[[extra.main_menu]]
-name_en = "Zola"
+name = "Zola"
name_de = "Zola"
url = "@/zola.md"
[[extra.main_menu]]
-name_en = "Blog"
+name = "Blog"
name_de = "Blog"
url = "@/blog/_index.md"
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
From cfe243132912e9a21e7de990836380f4356ba92d Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Sun, 18 Feb 2024 20:38:47 +0100
Subject: Fix nav with default language
---
templates/nav.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'templates')
diff --git a/templates/nav.html b/templates/nav.html
index ac3f44e..ba9f543 100644
--- a/templates/nav.html
+++ b/templates/nav.html
@@ -6,10 +6,10 @@
{% endif %}
{%- 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) %}
+ {% set title = item.name %}
{% else %}
+ {% set language_key = 'name_' ~ current_lang %}
{% set title = item[language_key] %}
{% endif %}
{%- if item.url is matching("https?://") %}
--
cgit 1.4.1
From 1c52ee3cc089e6b7ef8f38d1e6530b219239bd2e Mon Sep 17 00:00:00 2001
From: g4m4
Date: Mon, 19 Feb 2024 17:18:16 +0100
Subject: Translation link now pointing to the translation of the current page
---
templates/language_switcher.html | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'templates')
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
index b82ddfc..d3cd383 100644
--- a/templates/language_switcher.html
+++ b/templates/language_switcher.html
@@ -1,10 +1,15 @@
{% if config.extra.language_switcher %}
--
cgit 1.4.1
From 21091740f78eb4653cfc7e1dceba6f8856f3d210 Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Tue, 20 Feb 2024 17:04:48 +0100
Subject: Show language switcher on all pages
---
templates/language_switcher.html | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
(limited to 'templates')
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
index d3cd383..a300028 100644
--- a/templates/language_switcher.html
+++ b/templates/language_switcher.html
@@ -1,15 +1,11 @@
{% if config.extra.language_switcher %}
--
cgit 1.4.1
From f138825a20271b4c117ddd42ea6749a4378a9efb Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Tue, 20 Feb 2024 17:05:02 +0100
Subject: Add missing trailing slash to translation links
---
templates/language_switcher.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'templates')
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
index a300028..3af5e66 100644
--- a/templates/language_switcher.html
+++ b/templates/language_switcher.html
@@ -5,7 +5,7 @@
{%- if tr.code == lang %}
{{ tr.name }}
{%- else %}
- {{ tr.name }}
+ {{ tr.name }}
{%- endif %}
{%- endfor %}
--
cgit 1.4.1
From fa345b1d1e11cc66ed92605382887fd4367ef97a Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Tue, 20 Feb 2024 17:08:59 +0100
Subject: Make language switcher more semantic
---
templates/language_switcher.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'templates')
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
index 3af5e66..3968c73 100644
--- a/templates/language_switcher.html
+++ b/templates/language_switcher.html
@@ -1,11 +1,11 @@
{% if config.extra.language_switcher %}
-