forked from MapComplete/MapComplete
Add viewpoint for buurtnatuur, add translation of AddPointPoi
This commit is contained in:
parent
7bbc140f05
commit
c3d04c79b9
13 changed files with 271 additions and 71 deletions
|
@ -1,11 +1,48 @@
|
|||
import { UIElement } from "../UIElement"
|
||||
import {UIElement} from "../UIElement"
|
||||
import Locale from "./Locale"
|
||||
import {FixedUiElement} from "../Base/FixedUiElement";
|
||||
import {TagUtils} from "../../Logic/TagsFilter";
|
||||
import Combine from "../Base/Combine";
|
||||
|
||||
|
||||
export default class Translation extends UIElement {
|
||||
|
||||
private static forcedLanguage = undefined;
|
||||
|
||||
public Subs(text: any /*Map<string, string | UIElement>*/) {
|
||||
const newTranslations = {};
|
||||
for (const lang in this.translations) {
|
||||
let template: string = this.translations[lang];
|
||||
for (const k in text) {
|
||||
const combined = [];
|
||||
const parts = template.split("{" + k + "}");
|
||||
const el: string | UIElement = text[k];
|
||||
let rtext: string = "";
|
||||
console.log(parts)
|
||||
if (typeof (el) === "string") {
|
||||
rtext = el;
|
||||
} else {
|
||||
Translation.forcedLanguage = lang; // This is a very dirty hack - it'll bite me one day
|
||||
rtext = el.InnerRender();
|
||||
console.log(rtext)
|
||||
}
|
||||
for (let i = 0; i < parts.length - 1; i++) {
|
||||
combined.push(parts[i]);
|
||||
combined.push(rtext)
|
||||
}
|
||||
combined.push(parts[parts.length - 1]);
|
||||
template = new Combine(combined).InnerRender();
|
||||
}
|
||||
newTranslations[lang] = template;
|
||||
}
|
||||
Translation.forcedLanguage = undefined;
|
||||
return new Translation(newTranslations);
|
||||
|
||||
}
|
||||
|
||||
|
||||
get txt(): string {
|
||||
const txt = this.translations[Locale.language.data];
|
||||
const txt = this.translations[Translation.forcedLanguage ?? Locale.language.data];
|
||||
if (txt !== undefined) {
|
||||
return txt;
|
||||
}
|
||||
|
@ -36,8 +73,9 @@ export default class Translation extends UIElement {
|
|||
return new Translation(this.translations).Render();
|
||||
}
|
||||
|
||||
public Clone(){
|
||||
public Clone() {
|
||||
return new Translation(this.translations)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -391,7 +391,31 @@ export default class Translations {
|
|||
number: new T({
|
||||
en: "number",
|
||||
nl: "getal"
|
||||
})
|
||||
}),
|
||||
|
||||
add: {
|
||||
|
||||
addNew: new T({
|
||||
en: "Add a new {category} here",
|
||||
nl: "Voeg hier een {category} toe"
|
||||
}),
|
||||
header: new T({
|
||||
en: "<h2>No data</h2>You clicked somewhere where no data is known yet.<br/>",
|
||||
nl: "<h2>Geen selectie</h2>Je klikte ergens waar er nog geen data is.<br/>"
|
||||
}),
|
||||
pleaseLogin: new T({
|
||||
en: "<a class='activate-osm-authentication'>Please log in to add a new point</a>",
|
||||
nl: "<a class='activate-osm-authentication'>Gelieve je aan te melden om een punt to te voegen</a>"
|
||||
}),
|
||||
zoomInFurther: new T({
|
||||
en: "Zoom in further to add a point.",
|
||||
nl: "Gelieve verder in te zoomen om een punt toe te voegen"
|
||||
}),
|
||||
stillLoading: new T({
|
||||
en: "The data is still loading. Please wait a bit before you add a new point",
|
||||
nl: "De data wordt nog geladen. Nog even geduld en dan kan je een punt toevoegen."
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue