Chore: code cleanup

This commit is contained in:
Pieter Vander Vennet 2025-05-06 01:44:38 +02:00
parent 9186479cae
commit ea640468e8

View file

@ -191,26 +191,25 @@ export class Translation extends BaseUIElement {
InnerConstructElement(): HTMLElement {
const el = document.createElement("span")
const self = this
if (self.txt) {
el.innerHTML = self.txt
if (this.txt) {
el.innerHTML = this.txt
}
if (self.translations["*"] !== undefined) {
if (this.translations["*"] !== undefined) {
return el
}
Locale.language.addCallback((_) => {
if (self.isDestroyed) {
if (this.isDestroyed) {
return true
}
if (self.txt === undefined) {
if (this.txt === undefined) {
el.innerHTML = ""
} else {
el.innerHTML = self.txt
el.innerHTML = this.txt
}
})
if (self.context === undefined || self.context?.indexOf(":") < 0) {
if (this.context === undefined || this.context?.indexOf(":") < 0) {
return el
}
@ -220,7 +219,7 @@ export class Translation extends BaseUIElement {
if (!doShow) {
return
}
const linkToWeblate = new LinkToWeblate(self.context, self.translations)
const linkToWeblate = new LinkToWeblate(this.context, this.translations)
wrapper.appendChild(linkToWeblate.ConstructElement())
return true
})
@ -231,13 +230,7 @@ export class Translation extends BaseUIElement {
public SupportedLanguages(): string[] {
const langs = []
for (const translationsKey in this.translations) {
if (!this.translations.hasOwnProperty(translationsKey)) {
continue
}
if (translationsKey === "#") {
continue
}
if (!this.translations.hasOwnProperty(translationsKey)) {
if (translationsKey === "#" || translationsKey.startsWith("_")) {
continue
}
langs.push(translationsKey)