Fix missing labels (a11y)

Additionally add some missing translations
This commit is contained in:
daudix
2024-06-20 06:48:56 +03:00
parent 0a9b65d056
commit 7691b260a3
8 changed files with 62 additions and 44 deletions

View File

@ -22,6 +22,7 @@ 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_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_loading = "Loading"
comments_noscript = "Loading comments relies on JavaScript. Try enabling JavaScript and reloading, or visit the original post on Mastodon." comments_noscript = "Loading comments relies on JavaScript. Try enabling JavaScript and reloading, or visit the original post on Mastodon."
copy_code = "Copy code"
disclaimer = "Disclaimer" disclaimer = "Disclaimer"
drafted = "Drafted" drafted = "Drafted"
faves_from = "Favorites from" faves_from = "Favorites from"
@ -32,6 +33,7 @@ footer_powered_by = "Powered by"
footer_powered_by_and = "and" footer_powered_by_and = "and"
footer_source = "Website source" footer_source = "Website source"
go_to_top = "Go to Top" go_to_top = "Go to Top"
language = "Language"
load_comments = "Load Comments" load_comments = "Load Comments"
newest_to_oldest = "From newest to oldest" newest_to_oldest = "From newest to oldest"
open_post = "Open Post" open_post = "Open Post"
@ -65,6 +67,7 @@ comments = "Комментарии"
comments_description = "Вы можете оставить комментарий к этому блог-посту, публично ответив на него с помощью аккаунта Mastodon или другого аккаунта ActivityPub/Fediverse. Известные неприватные ответы отображены ниже." comments_description = "Вы можете оставить комментарий к этому блог-посту, публично ответив на него с помощью аккаунта Mastodon или другого аккаунта ActivityPub/Fediverse. Известные неприватные ответы отображены ниже."
comments_loading = "Загрузка…" comments_loading = "Загрузка…"
comments_noscript = "Загрузка комментариев зависит от JavaScript. Попробуйте включить JavaScript и перезагрузить, или посетите оригинальный пост на Mastodon." comments_noscript = "Загрузка комментариев зависит от JavaScript. Попробуйте включить JavaScript и перезагрузить, или посетите оригинальный пост на Mastodon."
copy_code = "Скопировать код"
disclaimer = "Дисклеймер" disclaimer = "Дисклеймер"
drafted = "Черновик" drafted = "Черновик"
faves_from = "Избранное с" faves_from = "Избранное с"
@ -75,6 +78,7 @@ footer_powered_by = "Работает на базе"
footer_powered_by_and = "и" footer_powered_by_and = "и"
footer_source = "Исходный код веб-сайта" footer_source = "Исходный код веб-сайта"
go_to_top = "Перейти в Начало" go_to_top = "Перейти в Начало"
language = "Язык"
load_comments = "Загрузить Комментарии" load_comments = "Загрузить Комментарии"
newest_to_oldest = "От новейшего к старейшему" newest_to_oldest = "От новейшего к старейшему"
open_post = "Открыть Пост" open_post = "Открыть Пост"
@ -108,6 +112,7 @@ comments = "التعليقات"
comments_description = "يمكنك التعليق على منشور المدونة هذا عن طريق الرد علنًا على هذا المنشور باستخدام حساب Mastodon أو حساب آخر على ActivityPub/Fediverse. يتم عرض الردود المعروفة غير الخاصة أدناه." comments_description = "يمكنك التعليق على منشور المدونة هذا عن طريق الرد علنًا على هذا المنشور باستخدام حساب Mastodon أو حساب آخر على ActivityPub/Fediverse. يتم عرض الردود المعروفة غير الخاصة أدناه."
comments_loading = "التحميل" comments_loading = "التحميل"
comments_noscript = "تحميل التعليقات يعتمد على JavaScript. حاول تمكين JavaScript وإعادة التحميل، أو قم بزيارة المنشور الأصلي على Mastodon." comments_noscript = "تحميل التعليقات يعتمد على JavaScript. حاول تمكين JavaScript وإعادة التحميل، أو قم بزيارة المنشور الأصلي على Mastodon."
copy_code = "نسخ الرمز"
disclaimer = "إخلاء المسؤولية" disclaimer = "إخلاء المسؤولية"
drafted = "مسودة" drafted = "مسودة"
faves_from = "المفضلة من" faves_from = "المفضلة من"
@ -118,6 +123,7 @@ footer_powered_by = "مدعوم من"
footer_powered_by_and = "و" footer_powered_by_and = "و"
footer_source = "مصدر الموقع الإلكتروني" footer_source = "مصدر الموقع الإلكتروني"
go_to_top = "الانتقال إلى الأعلى" go_to_top = "الانتقال إلى الأعلى"
language = "اللغة"
load_comments = "تحميل التعليقات" load_comments = "تحميل التعليقات"
newest_to_oldest = "من الأحدث إلى الأقدم" newest_to_oldest = "من الأحدث إلى الأقدم"
open_post = "افتح المنشور" open_post = "افتح المنشور"

9
sass/_hidden.scss Normal file
View File

@ -0,0 +1,9 @@
.hidden:not(:focus):not(:active) {
clip: rect(0 0 0 0);
position: absolute;
clip-path: inset(100%);
width: 1px;
height: 1px;
overflow: hidden;
white-space: nowrap;
}

View File

@ -141,10 +141,6 @@
width: 1rem; width: 1rem;
height: 1rem; height: 1rem;
} }
span {
display: none;
}
} }
&#feed .icon { &#feed .icon {

View File

@ -17,6 +17,7 @@
@use "external"; @use "external";
@use "footer"; @use "footer";
@use "general"; @use "general";
@use "hidden";
@use "icon"; @use "icon";
@use "input"; @use "input";
@use "media"; @use "media";

View File

@ -1,37 +0,0 @@
// Based on https://www.roboleary.net/2022/01/13/copy-code-to-clipboard-blog.html
document.addEventListener("DOMContentLoaded", function () {
let blocks = document.querySelectorAll("pre[class^='language-']");
blocks.forEach((block) => {
if (navigator.clipboard) {
let container = document.createElement("div");
container.classList.add("pre-container");
block.parentNode.insertBefore(container, block);
container.appendChild(block);
let button = document.createElement("button");
let icon = document.createElement("i");
icon.classList.add("icon");
button.appendChild(icon);
container.appendChild(button);
button.addEventListener("click", async () => {
await copyCode(block, button);
});
}
});
async function copyCode(block, button) {
let code = block.querySelector("code");
let text = code.innerText;
await navigator.clipboard.writeText(text);
button.classList.add("active");
setTimeout(() => {
button.classList.remove("active");
}, 800);
}
});

View File

@ -0,0 +1,43 @@
<script>
// Based on https://www.roboleary.net/2022/01/13/copy-code-to-clipboard-blog.html
document.addEventListener("DOMContentLoaded", function () {
let blocks = document.querySelectorAll("pre[class^='language-']");
blocks.forEach((block) => {
if (navigator.clipboard) {
let container = document.createElement("div");
container.classList.add("pre-container");
block.parentNode.insertBefore(container, block);
container.appendChild(block);
let button = document.createElement("button");
let icon = document.createElement("i");
let span = document.createElement("span");
icon.classList.add("icon");
span.classList.add("hidden");
span.innerHTML = "{{ trans(key='copy_code', lang=lang) }}";
button.appendChild(icon);
button.appendChild(span);
container.appendChild(button);
button.addEventListener("click", async () => {
await copyCode(block, button);
});
}
});
async function copyCode(block, button) {
let code = block.querySelector("code");
let text = code.innerText;
await navigator.clipboard.writeText(text);
button.classList.add("active");
setTimeout(() => {
button.classList.remove("active");
}, 800);
}
});
</script>

View File

@ -32,7 +32,7 @@
{% endif %} {% endif %}
{% if config.extra.show_copy_button %} {% if config.extra.show_copy_button %}
<script src="{{ get_url(path='copy-button.js') }}"></script> {% include "partials/copy-button.html" %}
{% endif %} {% endif %}
{% if config.extra.scripts %} {% if config.extra.scripts %}

View File

@ -49,7 +49,7 @@
<details> <details>
<summary> <summary>
<i class="icon"></i> <i class="icon"></i>
<span>Languages</span> <span class="hidden">{{ trans(key="language", lang=lang) }}</span>
</summary> </summary>
<ul> <ul>
{% for language in config.extra.nav.langs %} {% for language in config.extra.nav.langs %}
@ -65,7 +65,7 @@
<li id="feed"> <li id="feed">
<a href="{{ get_url(path=config.feed_filename) }}"> <a href="{{ get_url(path=config.feed_filename) }}">
<i class="icon"></i> <i class="icon"></i>
<span>{{ trans(key="feed", lang=lang) }}</span> <span class="hidden">{{ trans(key="feed", lang=lang) }}</span>
</a> </a>
</li> </li>
{% endif %} {% endif %}