More translation fixes, allows re-enabling questions (fix #51)

This commit is contained in:
Pieter Vander Vennet 2020-07-22 00:18:07 +02:00
parent 400d268651
commit 0bb5abec3c
10 changed files with 83 additions and 37 deletions

View file

@ -62,24 +62,19 @@ export default class BikeStations extends LayerDefinition {
const hasPump = self.pump.matchesProperties(properties) const hasPump = self.pump.matchesProperties(properties)
const isOperational = self.pumpOperationalOk.matchesProperties(properties) const isOperational = self.pumpOperationalOk.matchesProperties(properties)
const hasTools = self.tools.matchesProperties(properties) const hasTools = self.tools.matchesProperties(properties)
let iconName = "" let iconName = "repair_station.svg";
if (hasPump) { if (hasTools && hasPump && isOperational) {
if (hasTools) {
iconName = "repair_station_pump.svg" iconName = "repair_station_pump.svg"
} else { }else if(hasTools){
iconName = "repair_station.svg"
}else if(hasPump){
if (isOperational) { if (isOperational) {
iconName = "pump.svg" iconName = "pump.svg"
} else { } else {
iconName = "broken_pump.svg" iconName = "broken_pump.svg"
} }
} }
} else {
if (!self.pump.matchesProperties(properties)) {
iconName = "repair_station.svg"
} else {
iconName = "repair_station.svg"
}
}
const iconUrl = `./assets/bike/${iconName}` const iconUrl = `./assets/bike/${iconName}`
return { return {
color: "#00bb00", color: "#00bb00",

View file

@ -7,10 +7,10 @@ export default class PumpOperational extends TagRenderingOptions {
constructor() { constructor() {
const to = Translations.t.cyclofix.station.operational const to = Translations.t.cyclofix.station.operational
super({ super({
question: to.question.Render(), question: to.question,
mappings: [ mappings: [
{k: new Tag("service:bicycle:pump:operational_status","broken"), txt: to.broken.txt}, {k: new Tag("service:bicycle:pump:operational_status","broken"), txt: to.broken},
{k: new Tag("service:bicycle:pump:operational_status",""), txt: to.operational.txt} {k: new Tag("service:bicycle:pump:operational_status",""), txt: to.operational}
] ]
}); });
} }

View file

@ -7,21 +7,21 @@ export default class PumpValves extends TagRenderingOptions{
constructor() { constructor() {
const to = Translations.t.cyclofix.station.valves const to = Translations.t.cyclofix.station.valves
super({ super({
question: to.question.Render(), question: to.question,
mappings: [ mappings: [
{ {
k: new Tag("valves", " sclaverand;schrader;dunlop"), k: new Tag("valves", " sclaverand;schrader;dunlop"),
txt: to.default.Render() txt: to.default
}, },
{k: new Tag("valves", "dunlop"), txt: to.dunlop.Render()}, {k: new Tag("valves", "dunlop"), txt: to.dunlop},
{k: new Tag("valves", "sclaverand"), txt: to.sclaverand.Render()}, {k: new Tag("valves", "sclaverand"), txt: to.sclaverand},
{k: new Tag("valves", "auto"), txt: to.auto.Render()}, {k: new Tag("valves", "auto"), txt: to.auto},
], ],
freeform: { freeform: {
extraTags: new Tag("fixme", "Freeform valves= tag used: possibly a wrong value"), extraTags: new Tag("fixme", "Freeform valves= tag used: possibly a wrong value"),
key: "valves", key: "valves",
template: to.template.txt, template: to.template,
renderTemplate: to.render.txt renderTemplate: to.render
} }
}); });
} }

View file

@ -9,10 +9,10 @@ export default class ShopPump extends TagRenderingOptions {
const to = Translations.t.cyclofix.shop.diy const to = Translations.t.cyclofix.shop.diy
super({ super({
priority: 5, priority: 5,
question: to.question.Render(), question: to.question,
mappings: [ mappings: [
{k: new Tag(key, "yes"), txt: to.yes.Render()}, {k: new Tag(key, "yes"), txt: to.yes},
{k: new Tag(key, "no"), txt: to.no.Render()}, {k: new Tag(key, "no"), txt: to.no},
] ]
}); });
} }

View file

@ -9,10 +9,10 @@ export default class ShopPump extends TagRenderingOptions {
const to = Translations.t.cyclofix.shop.pump const to = Translations.t.cyclofix.shop.pump
super({ super({
priority: 5, priority: 5,
question: to.question.Render(), question: to.question,
mappings: [ mappings: [
{k: new Tag(key, "yes"), txt: to.yes.Render()}, {k: new Tag(key, "yes"), txt: to.yes},
{k: new Tag(key, "no"), txt: to.no.Render()}, {k: new Tag(key, "no"), txt: to.no},
] ]
}); });
} }

View file

@ -270,7 +270,7 @@ class TagRendering extends UIElement implements TagDependantUIElement {
} else { } else {
return "<span class='skip-button'>"+Translations.t.general.skip.R()+"</span>"; return "<span class='skip-button'>"+Translations.t.general.skip.R()+"</span>";
} }
}); }, [Locale.language]);
// And at last, set up the skip button // And at last, set up the skip button
this._skipButton = new VariableUiElement(cancelContents).onClick(cancel) ; this._skipButton = new VariableUiElement(cancelContents).onClick(cancel) ;
} }

View file

@ -11,6 +11,7 @@ import {OsmLink} from "../Customizations/Questions/OsmLink";
import {WikipediaLink} from "../Customizations/Questions/WikipediaLink"; import {WikipediaLink} from "../Customizations/Questions/WikipediaLink";
import {And} from "../Logic/TagsFilter"; import {And} from "../Logic/TagsFilter";
import {TagDependantUIElement, TagDependantUIElementConstructor} from "../Customizations/UIElementConstructor"; import {TagDependantUIElement, TagDependantUIElementConstructor} from "../Customizations/UIElementConstructor";
import Translations from "./i18n/Translations";
export class FeatureInfoBox extends UIElement { export class FeatureInfoBox extends UIElement {
@ -24,10 +25,13 @@ export class FeatureInfoBox extends UIElement {
private _wikipedialink: UIElement; private _wikipedialink: UIElement;
private _infoboxes: TagDependantUIElement[]; private _infoboxes: TagDependantUIElement[];
private _questions: QuestionPicker; private _questions: QuestionPicker;
private _oneSkipped = Translations.t.general.oneSkippedQuestion.Clone();
private _someSkipped = Translations.t.general.skippedQuestions.Clone();
constructor( constructor(
tagsES: UIEventSource<any>, tagsES: UIEventSource<any>,
title: TagRenderingOptions | UIElement, title: TagRenderingOptions | UIElement,
@ -45,10 +49,24 @@ export class FeatureInfoBox extends UIElement {
this._infoboxes = []; this._infoboxes = [];
elementsToShow = elementsToShow ?? [] elementsToShow = elementsToShow ?? []
const self = this;
for (const tagRenderingOption of elementsToShow) { for (const tagRenderingOption of elementsToShow) {
this._infoboxes.push( self._infoboxes.push(
tagRenderingOption.construct(deps)); tagRenderingOption.construct(deps));
} }
function initTags() {
self._infoboxes = []
for (const tagRenderingOption of elementsToShow) {
self._infoboxes.push(
tagRenderingOption.construct(deps));
}
self.Update();
}
this._someSkipped.onClick(initTags)
this._oneSkipped.onClick(initTags)
title = title ?? new TagRenderingOptions( title = title ?? new TagRenderingOptions(
{ {
@ -72,12 +90,15 @@ export class FeatureInfoBox extends UIElement {
const info = []; const info = [];
const questions: TagDependantUIElement[] = []; const questions: TagDependantUIElement[] = [];
let skippedQuestions = 0;
for (const infobox of this._infoboxes) { for (const infobox of this._infoboxes) {
if (infobox.IsKnown()) { if (infobox.IsKnown()) {
info.push(infobox); info.push(infobox);
} else if (infobox.IsQuestioning()) { } else if (infobox.IsQuestioning()) {
questions.push(infobox); questions.push(infobox);
} else {
// This question is neither known nor questioning -> it was skipped
skippedQuestions++;
} }
} }
@ -97,6 +118,10 @@ export class FeatureInfoBox extends UIElement {
} }
questionsHtml = mostImportantQuestion.Render(); questionsHtml = mostImportantQuestion.Render();
} else if (skippedQuestions == 1) {
questionsHtml = this._oneSkipped.Render();
} else if (skippedQuestions > 0) {
questionsHtml = this._someSkipped.Render();
} }
return "<div class='featureinfobox'>" + return "<div class='featureinfobox'>" +

View file

@ -36,4 +36,8 @@ export default class Translation extends UIElement {
return new Translation(this.translations).Render(); return new Translation(this.translations).Render();
} }
public Clone(){
return new Translation(this.translations)
}
} }

View file

@ -372,6 +372,14 @@ export default class Translations {
skip: new T({ skip: new T({
en: "Skip this question", en: "Skip this question",
nl: "Vraag overslaan" nl: "Vraag overslaan"
}),
oneSkippedQuestion: new T({
en: "One question is skipped",
nl: "Een vraag is overgeslaan"
}),
skippedQuestions: new T({
en: "Some questions are skipped",
nl: "Sommige vragen zijn overgeslaan"
}) })
} }
} }

14
docs/Create a theme.md Normal file
View file

@ -0,0 +1,14 @@
# Create a theme
A _layer_ is a set of features of a single kind, e.g. 'bookcases'.
A _layout_ is a set of layers, e.g. 'bookcases' + 'nature reserves'. They are shown together with some text on the left. They can be switched with the query parameter 'layout' in the url (thus by going to 'index.html?layout=bookcases')
If you want to make your own version of MapComplete, you create your own layout
- Clone the repo
- Build it
- Go into 'Customazations/Layouts' and copy a file there (e.g. bookcases)
- Change the text and layer selection
- Create you layers