forked from MapComplete/MapComplete
Full code cleanup
This commit is contained in:
parent
3a4a2a2016
commit
fa971ffbbf
300 changed files with 16352 additions and 19284 deletions
|
@ -7,13 +7,13 @@ export class Translation extends BaseUIElement {
|
|||
public static forcedLanguage = undefined;
|
||||
|
||||
public readonly translations: object
|
||||
|
||||
|
||||
constructor(translations: object, context?: string) {
|
||||
super()
|
||||
if (translations === undefined) {
|
||||
throw `Translation without content (${context})`
|
||||
}
|
||||
if(typeof translations === "string"){
|
||||
if (typeof translations === "string") {
|
||||
translations = {"*": translations};
|
||||
}
|
||||
let count = 0;
|
||||
|
@ -36,11 +36,6 @@ export class Translation extends BaseUIElement {
|
|||
get txt(): string {
|
||||
return this.textFor(Translation.forcedLanguage ?? Locale.language.data)
|
||||
}
|
||||
|
||||
Destroy() {
|
||||
super.Destroy();
|
||||
this.isDestroyed = true;
|
||||
}
|
||||
|
||||
static ExtractAllTranslationsFrom(object: any, context = ""): { context: string, tr: Translation }[] {
|
||||
const allTranslations: { context: string, tr: Translation }[] = []
|
||||
|
@ -74,6 +69,11 @@ export class Translation extends BaseUIElement {
|
|||
return new Translation(translations);
|
||||
}
|
||||
|
||||
Destroy() {
|
||||
super.Destroy();
|
||||
this.isDestroyed = true;
|
||||
}
|
||||
|
||||
public textFor(language: string): string {
|
||||
if (this.translations["*"]) {
|
||||
return this.translations["*"];
|
||||
|
@ -100,7 +100,7 @@ export class Translation extends BaseUIElement {
|
|||
const el = document.createElement("span")
|
||||
const self = this
|
||||
Locale.language.addCallbackAndRun(_ => {
|
||||
if(self.isDestroyed){
|
||||
if (self.isDestroyed) {
|
||||
return true
|
||||
}
|
||||
el.innerHTML = this.txt
|
||||
|
@ -124,8 +124,8 @@ export class Translation extends BaseUIElement {
|
|||
}
|
||||
return langs;
|
||||
}
|
||||
|
||||
public AllValues(): string[]{
|
||||
|
||||
public AllValues(): string[] {
|
||||
return this.SupportedLanguages().map(lng => this.translations[lng]);
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ export class Translation extends BaseUIElement {
|
|||
}
|
||||
return allIcons.filter(icon => icon != undefined)
|
||||
}
|
||||
|
||||
|
||||
AsMarkdown(): string {
|
||||
return this.txt
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue