fix: use alt-i18n-key to avoid overwriting alt tag which makes retranslation impossible

This commit is contained in:
2024-07-31 19:20:46 +02:00
parent 3831b81ec2
commit b7f2a3ed67
2 changed files with 5 additions and 7 deletions

View File

@@ -35,13 +35,11 @@ function translatePageElements() {
});
// Translate alt texts
const translatableAltTexts = document.querySelectorAll(
"[alt]",
"[alt-i18n-key]",
);
translatableAltTexts.forEach((el) => {
const translation_key = el.getAttribute("alt");
console.log(el);
const translation_key = el.getAttribute("alt-i18n-key");
el.setAttribute("alt", i18next.t(translation_key));
console.log(i18next.t(translation_key));
});
}