forked from MapComplete/MapComplete
Refactoring: remove some old, UIElement based code
This commit is contained in:
parent
56a55e8b54
commit
86667c1986
1 changed files with 9 additions and 10 deletions
|
@ -4,11 +4,15 @@ import BaseUIElement from "../BaseUIElement"
|
|||
import { Store } from "../../Logic/UIEventSource"
|
||||
import { VariableUiElement } from "../Base/VariableUIElement"
|
||||
|
||||
export class Translation extends VariableUiElement {
|
||||
export class Translation extends BaseUIElement {
|
||||
public static forcedLanguage = undefined
|
||||
|
||||
public readonly translations: Record<string, string>
|
||||
public readonly context?: string
|
||||
|
||||
private _current: Store<string>
|
||||
private _currentLanguage: Store<string>
|
||||
|
||||
/**
|
||||
* If a text is needed to display and is not available in the requested language,
|
||||
* it will default to english and - if this is not available - give any language it has available.
|
||||
|
@ -23,6 +27,8 @@ export class Translation extends VariableUiElement {
|
|||
context?: string,
|
||||
strictLanguages?: boolean
|
||||
) {
|
||||
super()
|
||||
|
||||
this._strictLanguages = strictLanguages
|
||||
|
||||
if (translations === undefined) {
|
||||
|
@ -37,9 +43,6 @@ export class Translation extends VariableUiElement {
|
|||
|
||||
let count = 0
|
||||
for (const translationsKey in translations) {
|
||||
if (!translations.hasOwnProperty(translationsKey)) {
|
||||
continue
|
||||
}
|
||||
if (
|
||||
translationsKey === "_context" ||
|
||||
translationsKey === "_meta" ||
|
||||
|
@ -77,12 +80,8 @@ export class Translation extends VariableUiElement {
|
|||
)
|
||||
}
|
||||
|
||||
super(this._current)
|
||||
}
|
||||
|
||||
private _current: Store<string>
|
||||
private _currentLanguage: Store<string>
|
||||
|
||||
/**
|
||||
* Indicates what language is effectively returned by `current`.
|
||||
* In most cases, this will be the language of choice, but if no translation is available, this will probably be `en`
|
||||
|
@ -221,8 +220,8 @@ export class Translation extends VariableUiElement {
|
|||
return this.OnEveryLanguage((str) => str.replace(new RegExp(a, "g"), b))
|
||||
}
|
||||
|
||||
public Clone() {
|
||||
return new Translation(this.translations, this.context)
|
||||
InnerConstructElement() {
|
||||
return new VariableUiElement(this.current).InnerConstructElement()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue