MapComplete/src/Utils/ariaLabel.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
753 B
TypeScript
Raw Normal View History

import { Translation } from "../UI/i18n/Translation"
2023-12-19 22:21:34 +01:00
import Locale from "../UI/i18n/Locale"
export function ariaLabel(htmlElement: Element, t: Translation) {
if (!t) {
return
}
let destroy: () => void = undefined
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"]
)
}
})
t.current.map(
(label) => {
htmlElement.setAttribute("aria-label", label)
},
[],
(f) => {
destroy = f
}
)
return { destroy }
}