Accessibility: add (translatable) aria labels, update to translation system, see #1181

This commit is contained in:
Pieter Vander Vennet 2023-12-12 19:18:50 +01:00
parent 825fd03adb
commit 8a7d8a43ce
12 changed files with 130 additions and 72 deletions

View file

@ -2,7 +2,6 @@
import { UIEventSource } from "../../Logic/UIEventSource.js"
export let value: UIEventSource<any>
let i: any = value.data
let htmlElement: HTMLSelectElement
function selectAppropriateValue() {
if (!htmlElement) {

View file

@ -3,36 +3,20 @@
* Properly renders a translation
*/
import { Translation } from "../i18n/Translation"
import { onDestroy } from "svelte"
import Locale from "../i18n/Locale"
import { Utils } from "../../Utils"
import FromHtml from "./FromHtml.svelte"
import WeblateLink from "./WeblateLink.svelte"
import { Store } from "../../Logic/UIEventSource"
export let t: Translation
export let cls: string = ""
export let tags: Record<string, string> | undefined = undefined
// Text for the current language
let txt: string | undefined
let txt: Store<string | undefined> = t.current
$: onDestroy(
Locale.language.addCallbackAndRunD((l) => {
const translation = t?.textFor(l)
if (translation === undefined) {
return
}
if (tags) {
txt = Utils.SubstituteKeys(txt, tags)
} else {
txt = translation
}
})
)
</script>
{#if t}
<span class={cls}>
<FromHtml src={txt} />
{$txt}
<WeblateLink context={t.context} />
</span>
{/if}