forked from MapComplete/MapComplete
Add better error messages when a translation is missing; add play forests
This commit is contained in:
parent
7a69847cda
commit
1c2646ae19
8 changed files with 156 additions and 13 deletions
|
@ -54,19 +54,19 @@ export default class LayerConfig {
|
|||
context = context + "." + json.id;
|
||||
const self = this;
|
||||
this.id = json.id;
|
||||
this.name = Translations.T(json.name);
|
||||
this.description = Translations.T(json.description);
|
||||
this.name = Translations.T(json.name, context+".name");
|
||||
this.description = Translations.T(json.description, context+".description");
|
||||
this.overpassTags = FromJSON.Tag(json.overpassTags, context + ".overpasstags");
|
||||
this.doNotDownload = json.doNotDownload ?? false,
|
||||
this.passAllFeatures = json.passAllFeatures ?? false;
|
||||
this.minzoom = json.minzoom;
|
||||
this.wayHandling = json.wayHandling ?? 0;
|
||||
this.hideUnderlayingFeaturesMinPercentage = json.hideUnderlayingFeaturesMinPercentage ?? 0;
|
||||
this.presets = (json.presets ?? []).map(pr =>
|
||||
this.presets = (json.presets ?? []).map((pr, i) =>
|
||||
({
|
||||
title: Translations.T(pr.title),
|
||||
title: Translations.T(pr.title, `${context}.presets[${i}].title`),
|
||||
tags: pr.tags.map(t => FromJSON.SimpleTag(t)),
|
||||
description: Translations.T(pr.description)
|
||||
description: Translations.T(pr.description, `${context}.presets[${i}].description`)
|
||||
}))
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ export default class LayoutConfig {
|
|||
} else {
|
||||
this.language = json.language;
|
||||
}
|
||||
if(this.language.length == 0){
|
||||
throw "No languages defined. Define at least one language"
|
||||
}
|
||||
if (json.title === undefined) {
|
||||
throw "Title not defined in " + this.id;
|
||||
}
|
||||
|
@ -62,7 +65,7 @@ export default class LayoutConfig {
|
|||
this.title = new Translation(json.title, context + ".title");
|
||||
this.description = new Translation(json.description, context + ".description");
|
||||
this.shortDescription = json.shortDescription === undefined ? this.description.FirstSentence() : new Translation(json.shortDescription, context + ".shortdescription");
|
||||
this.descriptionTail = json.descriptionTail === undefined ? new Translation({"*": ""}, context) : new Translation(json.descriptionTail, context + ".descriptionTail");
|
||||
this.descriptionTail = json.descriptionTail === undefined ? new Translation({"*": ""}, context+".descriptionTail") : new Translation(json.descriptionTail, context + ".descriptionTail");
|
||||
this.icon = json.icon;
|
||||
this.socialImage = json.socialImage;
|
||||
this.startZoom = json.startZoom;
|
||||
|
|
|
@ -45,13 +45,13 @@ export default class TagRenderingConfig {
|
|||
throw "Initing a TagRenderingConfig with undefined in " + context;
|
||||
}
|
||||
if (typeof json === "string") {
|
||||
this.render = Translations.T(json);
|
||||
this.render = Translations.T(json, context+".render");
|
||||
this.multiAnswer = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.render = Translations.T(json.render);
|
||||
this.question = Translations.T(json.question);
|
||||
this.render = Translations.T(json.render, context+".render");
|
||||
this.question = Translations.T(json.question, context+".question");
|
||||
this.roaming = json.roaming ?? false;
|
||||
const condition = FromJSON.Tag(json.condition ?? {"and": []}, `${context}.condition`);
|
||||
if (this.roaming && conditionIfRoaming !== undefined) {
|
||||
|
@ -96,10 +96,11 @@ export default class TagRenderingConfig {
|
|||
} else if (mapping.hideInAnswer !== undefined) {
|
||||
hideInAnswer = FromJSON.Tag(mapping.hideInAnswer, `${context}.mapping[${i}].hideInAnswer`);
|
||||
}
|
||||
const mappingContext = `${context}.mapping[${i}]`
|
||||
const mp = {
|
||||
if: FromJSON.Tag(mapping.if, `${context}.mapping[${i}].if`),
|
||||
ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${context}.mapping[${i}].ifnot`) : undefined),
|
||||
then: Translations.T(mapping.then),
|
||||
if: FromJSON.Tag(mapping.if, `${mappingContext}.if`),
|
||||
ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${mappingContext}.ifnot`) : undefined),
|
||||
then: Translations.T(mapping.then, `{mappingContext}.then`),
|
||||
hideInAnswer: hideInAnswer
|
||||
};
|
||||
if (this.question) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue