Make previous commit actually work

This is a huge mess, Zola is really not i18n-friendly
This commit is contained in:
daudix
2024-06-16 04:57:51 +03:00
parent a4a68c8b61
commit 7bb9b19e77
12 changed files with 68 additions and 49 deletions

View File

@ -2,6 +2,7 @@ title = "Duckquill"
base_url = "https://daudix.codeberg.page/duckquill"
description = "Modern, pretty, and clean theme."
default_language = "en"
compile_sass = true
minify_html = true
generate_feed = true
@ -10,7 +11,35 @@ build_search_index = false
author = "Duck Quack"
taxonomies = [{ name = "tags", feed = true }]
default_language = "en"
[translations]
archived = "Archived"
author = "Author"
comments = "Comments"
comments_description = "You can comment on this blog post by publicly replying to this post using a Mastodon or other ActivityPub/Fediverse account. Known non-private replies are displayed below."
comments_loading = "Loading…"
comments_noscript = "Loading comments relies on JavaScript. Try enabling JavaScript and reloading, or visit the original post on Mastodon."
disclaimer = "Disclaimer"
drafted = "Drafted"
feed = "Feed"
file_an_issue = "File an Issue"
filter_by_tag = "Filter by tag"
footer_powered_by = "Powered by"
footer_powered_by_and = "and"
footer_source = "Website source"
go_to_top = "Go to Top"
load_comments = "Load Comments"
newest_to_oldest = "From newest to oldest"
page_next = "Next"
page_previous = "Previous"
posts_in_total = "posts in total"
posts_with_tag = "Posts with tag"
see_all_tags = "See all tags"
skip_to_content = "Skip to main content"
table_of_contents = "Table of Contents"
tags = "Tags"
tags_in_total = "tags in total"
trigger_warning = "Trigger Warning"
[languages.ru]
title = "Duckquill"

View File

@ -11,7 +11,7 @@
</time>
{%- if page.authors %}
<span></span>
<span>{{ trans(key="author", default="Author", lang=lang) }}: {{ page.authors[0] }}</span>
<span>{{ trans(key="author", lang=lang) | default(value="Author") }}: {{ page.authors[0] }}</span>
{%- endif %}
{%- if page.taxonomies %}
{%- for name, taxon in page.taxonomies %}
@ -32,7 +32,7 @@
<div class="statement-container archive">
<strong class="big">
<i class="icon"></i>
{{ trans(key="archived", default="Archived", lang=lang) }}
{{ trans(key="archived", lang=lang) | default(value="Archived") }}
</strong>
{{ page.extra.archive | markdown | safe }}
</div>
@ -42,7 +42,7 @@
<div class="statement-container trigger">
<strong class="big">
<i class="icon"></i>
{{ trans(key="trigger_warning", default="Trigger Warning", lang=lang) }}
{{ trans(key="trigger_warning", lang=lang) | default(value="Trigger Warning") }}
</strong>
{{ page.extra.trigger | markdown | safe }}
</div>
@ -52,14 +52,14 @@
<div class="statement-container disclaimer">
<strong class="big">
<i class="icon"></i>
{{ trans(key="disclaimer", default="Disclaimer", lang=lang) }}
{{ trans(key="disclaimer", lang=lang) | default(value="Disclaimer") }}
</strong>
{{ page.extra.disclaimer | markdown | safe }}
</div>
{% endif %}
{% if page.extra.toc %}
<h2>{{ trans(key="table_of_contents", default="Table of Contents", lang=lang) }}</h2>
<h2>{{ trans(key="table_of_contents", lang=lang) | default(value="Table of Contents") }}</h2>
<ul>
{% for h1 in page.toc %}
<li>
@ -90,13 +90,13 @@
<nav id="post-nav">
{% if page.higher %}
<a class="post-nav-item post-nav-prev" href="{{ page.higher.permalink }}">
<div class="nav-arrow">← {{ trans(key="page_previous", default="Previous", lang=lang) }}</div>
<div class="nav-arrow">← {{ trans(key="page_previous", lang=lang) | default(value="Previous") }}</div>
<span class="post-title">{{ page.higher.title }}</span>
</a>
{% endif %}
{% if page.lower %}
<a class="post-nav-item post-nav-next" href="{{ page.lower.permalink }}">
<div class="nav-arrow">{{ trans(key="page_next", default="Next", lang=lang) }} →</div>
<div class="nav-arrow">{{ trans(key="page_next", lang=lang) | default(value="Next") }} →</div>
<span class="post-title">{{ page.lower.title }}</span>
</a>
{% endif %}
@ -104,9 +104,9 @@
{% endif %}
<div class="dialog-buttons">
<a class="inline-button" href="#top">{{ trans(key="go_to_top", default="Go to Top", lang=lang) }}</a>
<a class="inline-button" href="#top">{{ trans(key="go_to_top", lang=lang) | default(value="Go to Top") }}</a>
{% if config.extra.issues_url %}
<a class="inline-button colored" href="{{ config.extra.issues_url }}">{{ trans(key="file_an_issue", default="File an Issue", lang=lang) }}</a>
<a class="inline-button colored" href="{{ config.extra.issues_url }}">{{ trans(key="file_an_issue", lang=lang) | default(value="File an Issue") }}</a>
{% endif %}
</div>
{% endblock content %}

View File

@ -6,9 +6,9 @@
{{ section.description | markdown | safe }}
<small>
<a class="link-page" href="{{ get_url(path='tags', lang=lang) }}">{{ trans(key="filter_by_tag", default="Filter by tag", lang=lang) }}</a>
<a class="link-page" href="{{ get_url(path='tags', lang=lang) }}">{{ trans(key="filter_by_tag", lang=lang) | default(value="Filter by tag") }}</a>
<br />
{{ trans(key="newest_to_oldest", default="From newest to oldest", lang=lang) }} ↓
{{ trans(key="newest_to_oldest", lang=lang) | default(value="From newest to oldest") }} ↓
</small>
<div id="article-list">
@ -18,13 +18,13 @@
{%- if page.draft %}
<span class="draft-badge">
<i class="icon"></i>
{{ trans(key="drafted", default="Drafted", lang=lang) }}
{{ trans(key="drafted", lang=lang) | default(value="Drafted") }}
</span>
{%- endif %}
{%- if page.extra.archive %}
<span class="archive-badge">
<i class="icon"></i>
{{ trans(key="archived", default="Archived", lang=lang) }}
{{ trans(key="archived", lang=lang) | default(value="Archived") }}
</span>
{%- endif %}
{%- if page.description %}
@ -35,7 +35,7 @@
<time datetime="{{ page.date | date(format='%+') }}" pubdate>{{- page.date | date(format=config.extra.date_format) -}}</time>
{%- if page.authors %}
<span></span>
<span>{{ trans(key="author", default="Author", lang=lang) }}: {{ page.authors[0] }}</span>
<span>{{ trans(key="author", lang=lang) | default(value="Author") }}: {{ page.authors[0] }}</span>
{%- endif %}
{%- if page.taxonomies %}
{%- for name, taxon in page.taxonomies %}

View File

@ -1,12 +1,14 @@
{% set rtl = ["ar", "arc", "az", "dv", "ff", "he", "ku", "nqo", "fa", "rhg", "syc", "ur"] %}
<!DOCTYPE html>
<html lang="en">
{% include "partials/head.html" ignore missing %}
<body>
{% include "partials/nav.html" ignore missing %}
<html lang="{{ lang }}">
{% include "partials/head.html" %}
<body {% if lang in rtl %}dir="rtl"{% endif %}>
{% include "partials/nav.html" %}
<div id="main" class="container">
{% block custom %}{%- endblock -%}
{% block content %}{%- endblock -%}
</div>
{% include "partials/footer.html" ignore missing %}
{% include "partials/footer.html" %}
</body>
</html>

View File

@ -5,7 +5,7 @@
<div class="statement-container archive">
<strong class="big">
<i class="icon"></i>
{{ trans(key="archived", default="Archived", lang=lang) }}
{{ trans(key="archived", lang=lang) | default(value="Archived") }}
</strong>
{{ page.extra.archive | markdown | safe }}
</div>

View File

@ -20,16 +20,16 @@
<img id="qrcode" class="no-hover pixels" alt="QR code to a Mastodon post" src="https://api.qrserver.com/v1/create-qr-code/?data={{ post_url }}&format=gif" />
{% endif %}
<h2>{{ trans(key="comments", default="Comments", lang=lang) }}</h2>
<p>{{ trans(key="comments_description", default="You can comment on this blog post by publicly replying to this post using a Mastodon or other ActivityPub/Fediverse account. Known non-private replies are displayed below.", lang=lang) }}</p>
<h2>{{ trans(key="comments", lang=lang) | default(value="Comments") }}</h2>
<p>{{ trans(key="comments_description", lang=lang) | default(value="You can comment on this blog post by publicly replying to this post using a Mastodon or other ActivityPub/Fediverse account. Known non-private replies are displayed below.") }}</p>
<p>
<a id="load-comments" class="inline-button" onclick="loadComments()" onkeypress="loadComments()" tabindex="0">{{ trans(key="load_comments", default="Load Comments", lang=lang) }}</a>
<a id="load-comments" class="inline-button" onclick="loadComments()" onkeypress="loadComments()" tabindex="0">{{ trans(key="load_comments", lang=lang) | default(value="Load Comments") }}</a>
</p>
<div id="comments-wrapper">
<noscript>
<p>{{ trans(key="comments_noscript", default="Loading comments relies on JavaScript. Try enabling JavaScript and reloading, or visit the original post on Mastodon.", lang=lang) }}</p>
<p>{{ trans(key="comments_noscript", lang=lang) | default(value="Loading comments relies on JavaScript. Try enabling JavaScript and reloading, or visit the original post on Mastodon.") }}</p>
</noscript>
</div>
<script type="text/javascript">
@ -68,7 +68,7 @@
function loadComments() {
let commentsWrapper = document.getElementById("comments-wrapper");
document.getElementById("load-comments").innerHTML = "{{ trans(key='comments_loading', default='Loading…', lang=lang) }}";
document.getElementById("load-comments").innerHTML = "{{ trans(key='comments_loading', lang=lang) | default(value='Loading…') }}";
fetch("https://{{ host }}/api/v1/statuses/{{ id }}/context")
.then(function (response) {
return response.json();

View File

@ -5,14 +5,14 @@
{% if config.extra.source_url and config.extra.footer.show_source %}
<p>
<a href="{{ config.extra.source_url }}">{{ trans(key='footer_source', default="Website source", lang=lang) }}</a>
<a href="{{ config.extra.source_url }}">{{ trans(key='footer_source', lang=lang) | default(value="Website source") }}</a>
</p>
{% endif %}
{% if config.extra.footer.show_powered_by %}
<p>
<small>
{{ trans(key="footer_powered_by", default="Powered by", lang=lang) }} <a href="https://www.getzola.org">Zola</a> {{ trans(key="footer_powered_by_and", default="and", lang=lang) }} <a href="https://daudix.codeberg.page/duckquill">Duckquill</a>
{{ trans(key="footer_powered_by", lang=lang) | default(value="Powered by") }} <a href="https://www.getzola.org">Zola</a> {{ trans(key="footer_powered_by_and", lang=lang) | default(value="and") }} <a href="https://daudix.codeberg.page/duckquill">Duckquill</a>
</small>
</p>
{% endif %}

View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="{{ config.extra.primary_color }}" />
<link rel="canonical" href="{{ current_url | default(value='/') | safe }}" />
<title>{% block title %}{% include "partials/title.html" ignore missing %}{% endblock %}</title>
<title>{% block title %}{% include "partials/title.html" %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{{ get_url(path='style.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ get_url(path='syntax-theme-dark.css') }}" media="(prefers-color-scheme: dark)" />
<link rel="stylesheet" type="text/css" href="{{ get_url(path='syntax-theme-light.css') }}" media="(prefers-color-scheme: light)" />
@ -61,7 +61,7 @@
<!-- Open Graph -->
<meta property="og:site_name" content="{{ config.title }}" />
<meta property="og:title" content="{% include 'partials/title.html' ignore missing %}" />
<meta property="og:title" content="{% include 'partials/title.html' %}" />
<meta property="og:url" content="{{ current_url | default(value='/') | safe }}" />
<meta property="og:description" content="{{ page.description | default(value=config.description) }}" />
<meta property="og:image" content="{{ get_url(path='card.png') }}" />

View File

@ -1,12 +0,0 @@
{% if config.extra.language_switcher %}
<div class="lang" aria-label="{{ trans(key="language", lang=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 %}
<span class="active">{{ tr.name }}</span>
{% else %}
<a href="{{ get_url(path=language_agnostic_path, lang=tr.code) ~ "/" }}" hreflang="{{ tr.code }}" lang="{{ tr.code }}">{{ tr.name }}</a>
{% endif %}
{% endfor %}
</div>
{% endif %}

View File

@ -7,7 +7,7 @@
{% if config.extra.nav.links %}
<header id="site-nav">
<nav>
<a href="#main" id="main-content" tabindex="0">{{ trans(key="skip_to_content", default="Skip to main content", lang=lang) }}</a>
<a href="#main" id="main-content" tabindex="0">{{ trans(key="skip_to_content", lang=lang) | default(value="Skip to main content") }}</a>
<ul>
<li id="home">
<a href="{{ get_url(path='/', lang=lang) }}"
@ -48,7 +48,7 @@
<li id="feed">
<a href="{{ get_url(path=config.feed_filename) }}">
<i class="icon"></i>
<span>{{ trans(key="feed", default="Feed", lang=lang) }}</span>
<span>{{ trans(key="feed", lang=lang) | default(value="Feed") }}</span>
</a>
</li>
{% endif %}

View File

@ -1,8 +1,8 @@
{% extends "base.html" %}
{% block content %}
<h1>{{ trans(key="tags", default="Tags", lang=lang) }}</h1>
<small>{{ terms | length }} {{ trans(key="tags_in_total", default="tags in total", lang=lang) }}</small>
<h1>{{ trans(key="tags", lang=lang) | default(value="Tags") }}</h1>
<small>{{ terms | length }} {{ trans(key="tags_in_total", lang=lang) | default(value="tags in total") }}</small>
<br />
<small>
<ul class="tags">

View File

@ -1,11 +1,11 @@
{% extends "base.html" %}
{% block content %}
<h1>{{ trans(key="posts_with_tag", default="Posts with tag", lang=lang) }} “{{ term.name }}”</h1>
<h1>{{ trans(key="posts_with_tag", lang=lang) | default(value="Posts with tag") }} “{{ term.name }}”</h1>
<small>
<a class="link-page" href="{{ get_url(path='tags', lang=lang) }}">{{ trans(key="see_all_tags", default="See all tags", lang=lang) }}</a>
<a class="link-page" href="{{ get_url(path='tags', lang=lang) }}">{{ trans(key="see_all_tags", lang=lang) | default(value="See all tags") }}</a>
<br />
{{ term.pages | length }} {{ trans(key="posts_in_total", default="posts in total", lang=lang) }}
{{ term.pages | length }} {{ trans(key="posts_in_total", lang=lang) | default(value="posts in total") }}
</small>
<article>
{% for page in term.pages %}