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

@ -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 %}