Add translation buttons

This commit is contained in:
Pieter Vander Vennet 2022-04-01 12:51:55 +02:00
parent 592bc4ae0b
commit 2c7fb556dc
31 changed files with 442 additions and 150 deletions

View file

@ -9,6 +9,7 @@ import Combine from "./Base/Combine";
import BaseUIElement from "./BaseUIElement";
import {DefaultGuiState} from "./DefaultGuiState";
import FeaturePipelineState from "../Logic/State/FeaturePipelineState";
import LinkToWeblate from "./Base/LinkToWeblate";
export class SubstitutedTranslation extends VariableUiElement {
@ -34,6 +35,8 @@ export class SubstitutedTranslation extends VariableUiElement {
)
})
const linkToWeblate = new LinkToWeblate(translation.context, translation.translations)
super(
Locale.language.map(language => {
let txt = translation?.textFor(language);
@ -44,7 +47,7 @@ export class SubstitutedTranslation extends VariableUiElement {
txt = txt.replace(new RegExp(`{${key}}`, "g"), `{${key}()}`)
})
return new Combine(SubstitutedTranslation.ExtractSpecialComponents(txt, extraMappings).map(
const allElements = SubstitutedTranslation.ExtractSpecialComponents(txt, extraMappings).map(
proto => {
if (proto.fixed !== undefined) {
return new VariableUiElement(tagsSource.map(tags => Utils.SubstituteKeys(proto.fixed, tags)));
@ -56,8 +59,12 @@ export class SubstitutedTranslation extends VariableUiElement {
console.error("SPECIALRENDERING FAILED for", tagsSource.data?.id, e)
return new FixedUiElement(`Could not generate special rendering for ${viz.func.funcName}(${viz.args.join(", ")}) ${e}`).SetStyle("alert")
}
}
))
});
allElements.push(linkToWeblate)
return new Combine(
allElements
)
})
)