2023-12-12 19:18:50 +01:00
|
|
|
import { Translation } from "../UI/i18n/Translation"
|
2023-12-19 22:21:34 +01:00
|
|
|
import Locale from "../UI/i18n/Locale"
|
2023-12-12 19:18:50 +01:00
|
|
|
|
|
|
|
|
export function ariaLabel(htmlElement: Element, t: Translation) {
|
2023-12-14 18:25:35 +01:00
|
|
|
if (!t) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-12-13 02:16:53 +01:00
|
|
|
let destroy: () => void = undefined
|
2023-12-12 19:18:50 +01:00
|
|
|
|
2023-12-19 22:21:34 +01:00
|
|
|
Locale.language.map((language) => {
|
|
|
|
|
if (!t.translations[language]) {
|
|
|
|
|
console.log(
|
|
|
|
|
"No aria label in",
|
|
|
|
|
language,
|
|
|
|
|
"for",
|
|
|
|
|
t.context,
|
|
|
|
|
"; en is",
|
|
|
|
|
t.translations["en"]
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2023-12-12 19:18:50 +01:00
|
|
|
t.current.map(
|
|
|
|
|
(label) => {
|
|
|
|
|
htmlElement.setAttribute("aria-label", label)
|
|
|
|
|
},
|
|
|
|
|
[],
|
|
|
|
|
(f) => {
|
2023-12-13 02:16:53 +01:00
|
|
|
destroy = f
|
2023-12-12 19:18:50 +01:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2023-12-13 02:16:53 +01:00
|
|
|
return { destroy }
|
2023-12-12 19:18:50 +01:00
|
|
|
}
|