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 isOperational = self.pumpOperationalOk.matchesProperties(properties)
const hasTools = self.tools.matchesProperties(properties)
let iconName = ""
if (hasPump) {
if (hasTools) {
iconName = "repair_station_pump.svg"
} else {
if (isOperational) {
iconName = "pump.svg"
} else {
iconName = "broken_pump.svg"
}
}
} else {
if (!self.pump.matchesProperties(properties)) {
let iconName = "repair_station.svg";
if (hasTools && hasPump && isOperational) {
iconName = "repair_station_pump.svg"
}else if(hasTools){
iconName = "repair_station.svg"
}else if(hasPump){
if (isOperational) {
iconName = "pump.svg"
} else {
iconName = "repair_station.svg"
iconName = "broken_pump.svg"
}
}
const iconUrl = `./assets/bike/${iconName}`
return {
color: "#00bb00",

View file

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

View file

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

View file

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

View file

@ -270,7 +270,7 @@ class TagRendering extends UIElement implements TagDependantUIElement {
} else {
return "<span class='skip-button'>"+Translations.t.general.skip.R()+"</span>";
}
});
}, [Locale.language]);
// And at last, set up the skip button
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 {And} from "../Logic/TagsFilter";
import {TagDependantUIElement, TagDependantUIElementConstructor} from "../Customizations/UIElementConstructor";
import Translations from "./i18n/Translations";
export class FeatureInfoBox extends UIElement {
@ -24,10 +25,13 @@ export class FeatureInfoBox extends UIElement {
private _wikipedialink: UIElement;
private _infoboxes: TagDependantUIElement[];
private _questions: QuestionPicker;
private _oneSkipped = Translations.t.general.oneSkippedQuestion.Clone();
private _someSkipped = Translations.t.general.skippedQuestions.Clone();
constructor(
tagsES: UIEventSource<any>,
title: TagRenderingOptions | UIElement,
@ -41,14 +45,28 @@ export class FeatureInfoBox extends UIElement {
this._userDetails = userDetails;
this.ListenTo(userDetails);
const deps = {tags:this._tagsES , changes:this._changes}
const deps = {tags: this._tagsES, changes: this._changes}
this._infoboxes = [];
elementsToShow = elementsToShow ?? []
const self = this;
for (const tagRenderingOption of elementsToShow) {
this._infoboxes.push(
self._infoboxes.push(
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(
{
@ -71,13 +89,16 @@ export class FeatureInfoBox extends UIElement {
const info = [];
const questions : TagDependantUIElement[] = [];
const questions: TagDependantUIElement[] = [];
let skippedQuestions = 0;
for (const infobox of this._infoboxes) {
if (infobox.IsKnown()) {
info.push(infobox);
} else if (infobox.IsQuestioning()) {
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();
} else if (skippedQuestions == 1) {
questionsHtml = this._oneSkipped.Render();
} else if (skippedQuestions > 0) {
questionsHtml = this._someSkipped.Render();
}
return "<div class='featureinfobox'>" +

View file

@ -36,4 +36,8 @@ export default class Translation extends UIElement {
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({
en: "Skip this question",
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