diff --git a/Models/ThemeConfig/Conversion/PrepareLayer.ts b/Models/ThemeConfig/Conversion/PrepareLayer.ts index ae3860ce8..85ca9509e 100644 --- a/Models/ThemeConfig/Conversion/PrepareLayer.ts +++ b/Models/ThemeConfig/Conversion/PrepareLayer.ts @@ -526,7 +526,7 @@ export class RewriteSpecial extends DesugaringStep { * // should warn for unexpected keys * const errors = [] * RewriteSpecial.convertIfNeeded({"special": {type: "image_carousel"}, "en": "xyz"}, errors, "test") // => {'*': "{image_carousel()}"} - * errors // => ["The only keys allowed next to a 'special'-block are 'before' and 'after'. Perhaps you meant to put 'en' into the special block?"] + * errors // => ["At test: The only keys allowed next to a 'special'-block are 'before' and 'after'. Perhaps you meant to put 'en' into the special block?"] * * // should give an error on unknown visualisations * const errors = [] @@ -593,7 +593,7 @@ export class RewriteSpecial extends DesugaringStep { ...Array.from(Object.keys(input)) .filter((k) => k !== "special" && k !== "before" && k !== "after") .map((k) => { - return `The only keys allowed next to a 'special'-block are 'before' and 'after'. Perhaps you meant to put '${k}' into the special block?` + return `At ${context}: The only keys allowed next to a 'special'-block are 'before' and 'after'. Perhaps you meant to put '${k}' into the special block?` }) ) @@ -610,7 +610,7 @@ export class RewriteSpecial extends DesugaringStep { argNamesList, (x) => x ) - return `Unexpected argument in special block at ${context} with name '${wrongArg}'. Did you mean ${ + return `At ${context}: Unexpected argument in special block at ${context} with name '${wrongArg}'. Did you mean ${ byDistance[0] }?\n\tAll known arguments are ${argNamesList.join(", ")}` }) @@ -623,7 +623,7 @@ export class RewriteSpecial extends DesugaringStep { } const param = special[arg.name] if (param === undefined) { - errors.push(`Obligated parameter '${arg.name}' not found`) + errors.push(`At ${context}: Obligated parameter '${arg.name}' in special rendering of type ${vis.funcName} not found.\n${arg.doc}`) } } @@ -735,7 +735,7 @@ export class RewriteSpecial extends DesugaringStep { continue } Utils.WalkPath(path.path, json, (leaf, travelled) => - RewriteSpecial.convertIfNeeded(leaf, errors, travelled.join(".")) + RewriteSpecial.convertIfNeeded(leaf, errors, context + ":" + travelled.join(".")) ) } diff --git a/Models/ThemeConfig/Conversion/Validation.ts b/Models/ThemeConfig/Conversion/Validation.ts index c316aa879..8561cb446 100644 --- a/Models/ThemeConfig/Conversion/Validation.ts +++ b/Models/ThemeConfig/Conversion/Validation.ts @@ -1,19 +1,19 @@ -import { DesugaringStep, Each, Fuse, On } from "./Conversion" -import { LayerConfigJson } from "../Json/LayerConfigJson" +import {DesugaringStep, Each, Fuse, On} from "./Conversion" +import {LayerConfigJson} from "../Json/LayerConfigJson" import LayerConfig from "../LayerConfig" -import { Utils } from "../../../Utils" +import {Utils} from "../../../Utils" import Constants from "../../Constants" -import { Translation } from "../../../UI/i18n/Translation" -import { LayoutConfigJson } from "../Json/LayoutConfigJson" +import {Translation} from "../../../UI/i18n/Translation" +import {LayoutConfigJson} from "../Json/LayoutConfigJson" import LayoutConfig from "../LayoutConfig" -import { TagRenderingConfigJson } from "../Json/TagRenderingConfigJson" -import { TagUtils } from "../../../Logic/Tags/TagUtils" -import { ExtractImages } from "./FixImages" +import {TagRenderingConfigJson} from "../Json/TagRenderingConfigJson" +import {TagUtils} from "../../../Logic/Tags/TagUtils" +import {ExtractImages} from "./FixImages" import ScriptUtils from "../../../scripts/ScriptUtils" -import { And } from "../../../Logic/Tags/And" +import {And} from "../../../Logic/Tags/And" import Translations from "../../../UI/i18n/Translations" import Svg from "../../../Svg" -import { QuestionableTagRenderingConfigJson } from "../Json/QuestionableTagRenderingConfigJson" +import {QuestionableTagRenderingConfigJson} from "../Json/QuestionableTagRenderingConfigJson" import FilterConfigJson from "../Json/FilterConfigJson" import DeleteConfig from "../DeleteConfig" @@ -617,6 +617,24 @@ export class DetectMappingsWithImages extends DesugaringStep { + constructor() { + super("Miscellanious checks on the tagrendering", ["special"], "MiscTagREnderingChecksRew"); + } + + convert(json: TagRenderingConfigJson, context: string): { result: TagRenderingConfigJson; errors?: string[]; warnings?: string[]; information?: string[] } { + const errors = [] + if(json["special"] !== undefined){ + errors.push("At "+context+": detected `special` on the top level. Did you mean `{\"render\":{ \"special\": ... }}`") + } + return { + result: json, + errors + }; + } + +} + export class ValidateTagRenderings extends Fuse { constructor(layerConfig?: LayerConfigJson, doesImageExist?: DoesImageExist) { super( diff --git a/Models/ThemeConfig/FilterConfig.ts b/Models/ThemeConfig/FilterConfig.ts index a95dc3b29..cd0b654f5 100644 --- a/Models/ThemeConfig/FilterConfig.ts +++ b/Models/ThemeConfig/FilterConfig.ts @@ -66,21 +66,24 @@ export default class FilterConfig { }) for (const field of fields) { - question.OnEveryLanguage((txt, language) => { + for (let ln in question.translations) { + const txt = question.translations[ln] + if(ln.startsWith("_")){ + continue + } if (txt.indexOf("{" + field.name + "}") < 0) { throw ( "Error in filter with fields at " + context + ".question." + - language + + ln + ": The question text should contain every field, but it doesn't contain `{" + field + "}`: " + txt ) } - return txt - }) + } } if (option.default) { diff --git a/Models/ThemeConfig/TagRenderingConfig.ts b/Models/ThemeConfig/TagRenderingConfig.ts index e1f9de872..90f77cc01 100644 --- a/Models/ThemeConfig/TagRenderingConfig.ts +++ b/Models/ThemeConfig/TagRenderingConfig.ts @@ -239,6 +239,9 @@ export default class TagRenderingConfig { throw `${context}: Detected a freeform key without rendering... Key: ${this.freeform.key} in ${context}` } for (const ln in this.render.translations) { + if(ln.startsWith("_")){ + continue + } const txt: string = this.render.translations[ln] if (txt === "") { throw context + " Rendering for language " + ln + " is empty" diff --git a/UI/LanguagePicker.ts b/UI/LanguagePicker.ts index 3b1f608a7..5a7cef769 100644 --- a/UI/LanguagePicker.ts +++ b/UI/LanguagePicker.ts @@ -42,6 +42,9 @@ export default class LanguagePicker extends Toggle { return new Translation({ "*": nativeText }) } for (const key in trans) { + if(key.startsWith("_")){ + continue + } const translationInKey = allTranslations[lang][key] if (nativeText.toLowerCase() === translationInKey.toLowerCase()) { translation[key] = nativeText diff --git a/UI/i18n/Translation.ts b/UI/i18n/Translation.ts index 3a7eb7c3f..adf641941 100644 --- a/UI/i18n/Translation.ts +++ b/UI/i18n/Translation.ts @@ -16,10 +16,6 @@ export class Translation extends BaseUIElement { throw `Translation without content (${context})` } this.context = translations["_context"] ?? context - if (translations["_context"] !== undefined) { - translations = { ...translations } - delete translations["_context"] - } if (typeof translations === "string") { translations = { "*": translations } } @@ -28,7 +24,7 @@ export class Translation extends BaseUIElement { if (!translations.hasOwnProperty(translationsKey)) { continue } - if (translationsKey === "_context") { + if (translationsKey === "_context" || translationsKey === "_meta") { continue } count++