Spaces:
Running
Running
File size: 588 Bytes
f23825d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import { localized } from "../common/localize/localizedString"
const localizeElement = (e: Element) => {
const key = e.getAttribute("data-i18n")
if (key !== null) {
const text = localized(key)
if (text !== undefined) {
e.textContent = text
}
}
}
const localize = () => {
document.querySelectorAll("*[data-i18n]").forEach(localizeElement)
const title = document.getElementsByTagName("title")[0]
if (title) {
localizeElement(title)
}
}
window.addEventListener("DOMContentLoaded", (e) => {
console.log("DOM fully loaded and parsed")
localize()
})
|