diff options
author | Alan Pearce | 2024-02-20 20:02:36 +0000 |
---|---|---|
committer | Alan Pearce | 2024-02-20 20:02:36 +0000 |
commit | 333e97f135264c3c220063b2b64bf4dc0b508f34 (patch) | |
tree | fda555ec02ad606d42d089b01107cbfead01f68d /templates | |
parent | 5a936b5c413b541c5523da6b4ebdc46f996f7360 (diff) | |
parent | fa345b1d1e11cc66ed92605382887fd4367ef97a (diff) | |
download | zola-bearblog-333e97f135264c3c220063b2b64bf4dc0b508f34.tar.lz zola-bearblog-333e97f135264c3c220063b2b64bf4dc0b508f34.tar.zst zola-bearblog-333e97f135264c3c220063b2b64bf4dc0b508f34.zip |
Merge pull request 'Basic multilingual site' (#10) from multilingual into main
Reviewed-on: https://codeberg.org/alanpearce/zola-bearblog/pulls/10
Diffstat (limited to 'templates')
-rw-r--r-- | templates/footer.html | 2 | ||||
-rw-r--r-- | templates/header.html | 1 | ||||
-rw-r--r-- | templates/language_switcher.html | 12 | ||||
-rw-r--r-- | templates/nav.html | 16 | ||||
-rw-r--r-- | templates/section.html | 8 | ||||
-rw-r--r-- | templates/taxonomy_list.html | 2 | ||||
-rw-r--r-- | templates/taxonomy_single.html | 2 |
7 files changed, 34 insertions, 9 deletions
diff --git a/templates/footer.html b/templates/footer.html index c952a93..6d4f0f7 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,5 +1,5 @@ <footer> {%- if not config.extra.hide_made_with_line %} - Made with <a href="https://codeberg.org/alanpearce/zola-bearblog">Zola ʕ•ᴥ•ʔ Bear</a> + {{ trans(key="made_with", lang=lang) }} <a href="https://codeberg.org/alanpearce/zola-bearblog">Zola ʕ•ᴥ•ʔ Bear</a> {%- endif %} </footer> 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 @@ <header> + {% include "language_switcher.html" %} <a href="{{ get_url(path="@/_index.md", lang=lang) }}" class="title"> <h1>{{ config.title }}</h1> </a> diff --git a/templates/language_switcher.html b/templates/language_switcher.html new file mode 100644 index 0000000..3968c73 --- /dev/null +++ b/templates/language_switcher.html @@ -0,0 +1,12 @@ +{% if config.extra.language_switcher %} + <nav class="lang"> + {%- set language_agnostic_path = current_path | default(value="/") | replace(from='/' ~ lang ~ '/', to = '/') | trim_start_matches(pat = '/') -%} + {%- for tr in config.extra.translations %} + {%- if tr.code == lang %} + <strong>{{ tr.name }}</strong> + {%- else %} + <a href="{{ get_url(path=language_agnostic_path, lang=tr.code) ~ "/" }}" hreflang="{{ tr.code }}">{{ tr.name }}</a> + {%- endif %} + {%- endfor %} + </nav> +{% endif %} diff --git a/templates/nav.html b/templates/nav.html index a71652e..ba9f543 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -1,9 +1,21 @@ +{% set current_lang = config.default_language %} +{% if page %} + {% set current_lang = page.lang %} +{% elif section %} + {% set current_lang = section.lang %} +{% endif %} {%- if config.extra.main_menu %} {%- for item in config.extra.main_menu %} + {% if current_lang == config.default_language %} + {% set title = item.name %} + {% else %} + {% set language_key = 'name_' ~ current_lang %} + {% set title = item[language_key] %} + {% endif %} {%- if item.url is matching("https?://") %} - <a href="{{ item.url }}">{{ item.name }}</a> + <a href="{{ item.url }}">{{ title }}</a> {%- else %} - <a href="{{ get_url(path=item.url, lang=lang )}}">{{ item.name }}</a> + <a href="{{ get_url(path=item.url, lang=lang )}}">{{ title }}</a> {%- endif %} {%- endfor %} {%- endif -%} diff --git a/templates/section.html b/templates/section.html index f3c218a..9560719 100644 --- a/templates/section.html +++ b/templates/section.html @@ -3,9 +3,9 @@ {% block main %} <main> {%- if taxonomy.term %} - <h3 class="filter">Filtering for "{{ section.title }}"</h3> + <h3 class="filter">{{ trans(key="filtering_for",lang=lang)}} "{{ section.title }}"</h3> <small> - <a href="{{ get_url(path="@/blog/_index.md", lang=lang) }}">Remove filter</a> + <a href="{{ get_url(path="@/blog/_index.md", lang=lang) }}">{{ trans(key="remove_filter", lang=lang) }}</a> </small> {%- endif %} <ul class="blog-posts"> @@ -22,13 +22,13 @@ </li> {% else %} <li> - No posts yet + {{ trans(key="no_posts", lang=lang) }} </li> {% endfor %} </ul> <small> <div> - {% set tags = get_taxonomy(kind="tags") %} + {% set tags = get_taxonomy(kind="tags", lang=lang) %} {% for post in tags.items %} <a href="{{ post.permalink }}">#{{ post.name }}</a> {% endfor %} diff --git a/templates/taxonomy_list.html b/templates/taxonomy_list.html index 98b8fc9..4b4e08a 100644 --- a/templates/taxonomy_list.html +++ b/templates/taxonomy_list.html @@ -5,7 +5,7 @@ <h1>{{ taxonomy.name | capitalize }}</h1> <small> <div> - {% set tags = get_taxonomy(kind="tags") %} + {% set tags = get_taxonomy(kind="tags", lang=lang) %} {% for post in tags.items %} <a href="{{ post.permalink }}">#{{ post.name }}</a> {% 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 @@ </li> {% else %} <li> - No posts yet + {{ trans(key="no_posts", lang=lang) }} </li> {% endfor %} </ul> |