Add accessilbilty check and fixes
Some checks failed
/ build (push) Successful in 15s
/ accessibility (push) Failing after 23s

This commit is contained in:
Stefan Bethke 2026-10-17 10:03:54 +02:00
commit 71098eb6d7
13 changed files with 132 additions and 29 deletions

View file

@ -1,21 +1,25 @@
{{- /* Language badge for a tour. Params: code ("de", "en" or "deen"), class (optional; without it the badge is styled as an inline superscript). */ -}}
{{- /* Language badge for a tour. Params: code ("de", "en" or "deen"), class (optional; without it the badge is styled as an inline superscript).
The visible label ("DE/EN") is hidden from screen readers, which read a short text instead; the full sentence is a tooltip. */ -}}
{{- $code := .code | lower -}}
{{- $validCodes := slice "de" "en" "deen" -}}
{{- if not (in $validCodes $code) -}}
<span style="color: red; font-weight: bold;">Warning: Invalid or missing language code '{{ $code }}'. Use 'de', 'en', or 'deen'.</span>
{{- else -}}
{{- $label := cond (eq $code "de") "DE" (cond (eq $code "en") "EN" (cond (eq $code "deen") "DE/EN" "")) -}}
{{- $de := eq site.Language.Name "de" -}}
{{- $label := cond (eq $code "de") "DE" (cond (eq $code "en") "EN" "DE/EN") -}}
{{- $title := "" -}}
{{- $spoken := "" -}}
{{- if eq $code "deen" -}}
{{- $title = cond (eq site.Language.Name "de") "Diese Tour wird zweisprachig stattfinden (Deutsch und Englisch)" "This tour will be bilingual (German and English)" -}}
{{- $title = cond $de "Diese Tour wird zweisprachig stattfinden (Deutsch und Englisch)" "This tour will be bilingual (German and English)" -}}
{{- $spoken = cond $de "Sprache: Deutsch und Englisch" "Language: German and English" -}}
{{- else if eq $code "de" -}}
{{- $title = cond (eq site.Language.Name "de") "Diese Tour wird auf Deutsch stattfinden" "This tour will be held in German" -}}
{{- $title = cond $de "Diese Tour wird auf Deutsch stattfinden" "This tour will be held in German" -}}
{{- $spoken = cond $de "Sprache: Deutsch" "Language: German" -}}
{{- else if eq $code "en" -}}
{{- $title = cond (eq site.Language.Name "de") "Diese Tour wird auf Englisch stattfinden" "This tour will be held in English" -}}
{{- end -}}
{{- with .class -}}
<abbr class="{{ . }}" title="{{ $title }}">{{ $label }}</abbr>
{{- else -}}
<abbr style="font-size: .65em; vertical-align: super;" title="{{ $title }}">{{ $label }}</abbr>
{{- $title = cond $de "Diese Tour wird auf Englisch stattfinden" "This tour will be held in English" -}}
{{- $spoken = cond $de "Sprache: Englisch" "Language: English" -}}
{{- end -}}
{{- $style := "font-size: .65em; vertical-align: super;" -}}
{{- with .class }}{{ $style = "" }}{{ end -}}
<span{{ with .class }} class="{{ . }}"{{ end }}{{ with $style }} style="{{ . | safeCSS }}"{{ end }} title="{{ $title }}"><span aria-hidden="true">{{ $label }}</span><span class="visually-hidden">{{ $spoken }}</span></span>
{{- end -}}