forked from MapComplete/MapComplete
		
	Full translations
This commit is contained in:
		
							parent
							
								
									33a1e47af2
								
							
						
					
					
						commit
						400d268651
					
				
					 18 changed files with 114 additions and 194 deletions
				
			
		| 
						 | 
				
			
			@ -13,7 +13,7 @@ import ParkingOperator from "../Questions/bike/ParkingOperator";
 | 
			
		|||
export default class BikeParkings extends LayerDefinition {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super();
 | 
			
		||||
        this.name = Translations.t.cyclofix.parking.name.txt;
 | 
			
		||||
        this.name = Translations.t.cyclofix.parking.name;
 | 
			
		||||
        this.icon = "./assets/bike/parking.svg";
 | 
			
		||||
        this.overpassFilter = new Tag("amenity", "bicycle_parking");
 | 
			
		||||
        this.newElementTags = [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,122 +0,0 @@
 | 
			
		|||
import {TagRenderingOptions} from "../TagRendering";
 | 
			
		||||
import {LayerDefinition} from "../LayerDefinition";
 | 
			
		||||
import {And, Tag} from "../../Logic/TagsFilter";
 | 
			
		||||
import L from "leaflet";
 | 
			
		||||
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
 | 
			
		||||
import {NameQuestion} from "../Questions/NameQuestion";
 | 
			
		||||
 | 
			
		||||
export class BikeShop extends LayerDefinition {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private readonly sellsBikes = new Tag("service:bicycle:retail", "yes");
 | 
			
		||||
    private readonly repairsBikes = new Tag("service:bicycle:repair", "yes");
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super(
 | 
			
		||||
            {
 | 
			
		||||
                name: "bike shop or repair",
 | 
			
		||||
                icon: "assets/bike/repair_shop.svg",
 | 
			
		||||
                minzoom: 14,
 | 
			
		||||
                overpassFilter: new Tag("shop", "bicycle"),
 | 
			
		||||
                newElementTags: [new Tag("shop", "bicycle")]
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        this.title = new TagRenderingOptions({
 | 
			
		||||
            mappings: [
 | 
			
		||||
                {k: new And([new Tag("name", "*"), this.sellsBikes]), txt: "Bicycle shop {name}"},
 | 
			
		||||
                {
 | 
			
		||||
                    k: new And([new Tag("name", "*"), new Tag("service:bicycle:retail", "no")]),
 | 
			
		||||
                    txt: "Bicycle repair {name}",
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    k: new And([new Tag("name", "*"), new Tag("service:bicycle:retail", "")]),
 | 
			
		||||
                    txt: "Bicycle repair {name}"
 | 
			
		||||
                },
 | 
			
		||||
 | 
			
		||||
                {k: this.sellsBikes, txt: "Bicycle shop"},
 | 
			
		||||
                {k: new Tag("service:bicycle:retail", "no"), txt: "Bicycle repair"},
 | 
			
		||||
                {k: new Tag("service:bicycle:retail", ""), txt: "Bicycle repair/shop"},
 | 
			
		||||
            ]
 | 
			
		||||
        })
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        this.elementsToShow = [
 | 
			
		||||
            new ImageCarouselWithUploadConstructor(),
 | 
			
		||||
            new TagRenderingOptions({
 | 
			
		||||
                question: "What is the name of this bicycle shop?",
 | 
			
		||||
                freeform: {
 | 
			
		||||
                    key: "name",
 | 
			
		||||
                    renderTemplate: "The name of this bicycle shop is {name}",
 | 
			
		||||
                    template: "The name of this bicycle shop is $$$"
 | 
			
		||||
                }
 | 
			
		||||
            }),
 | 
			
		||||
 | 
			
		||||
            new TagRenderingOptions({
 | 
			
		||||
                question: "Can one buy a bike here?",
 | 
			
		||||
                mappings: [
 | 
			
		||||
                    {k: this.sellsBikes, txt: "Bikes are sold here"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:retail", "no"), txt: "No bikes are sold here"},
 | 
			
		||||
                ]
 | 
			
		||||
            }),
 | 
			
		||||
 | 
			
		||||
            new TagRenderingOptions({
 | 
			
		||||
                question: "Can one buy a new bike here?",
 | 
			
		||||
                mappings: [
 | 
			
		||||
                    {k: new Tag("service:bicycle:second_hand", "yes"), txt: "Second-hand bikes are sold here"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:second_hand", "only"), txt: "All bicycles sold here are second-hand"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:second_hand", "no"), txt: "Only brand new bikes are sold here"},
 | 
			
		||||
                ]
 | 
			
		||||
            }).OnlyShowIf(this.sellsBikes),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            new TagRenderingOptions({
 | 
			
		||||
                question: "Does this shop repair bicycles?",
 | 
			
		||||
                mappings: [
 | 
			
		||||
                    {k: this.repairsBikes, txt: "Bikes are repaired here, by the shop owner (for a fee)"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:repair", "only_sold"), txt: "Only bikes that were bought here, are repaired"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:repair", "brand"), txt: "Only bikes of a fixed brand are repaired here"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:repair", "no"), txt: "Bikes are not repaired here"},
 | 
			
		||||
                ]
 | 
			
		||||
            }),
 | 
			
		||||
 | 
			
		||||
            new TagRenderingOptions({
 | 
			
		||||
                question: "Can one hire a new bike here?",
 | 
			
		||||
                mappings: [
 | 
			
		||||
                    {k: new Tag("service:bicycle:rental", "yes"), txt: "Bikes can be rented here"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:rental", "no"), txt:  "Bikes cannot be rented here"},
 | 
			
		||||
                ]
 | 
			
		||||
            }).OnlyShowIf(this.sellsBikes),
 | 
			
		||||
 | 
			
		||||
            new TagRenderingOptions({
 | 
			
		||||
                question: "Are there tools here so that one can repair their own bike?",
 | 
			
		||||
                mappings: [
 | 
			
		||||
                    {k: new Tag("service:bicycle:diy", "yes"), txt: "Tools for DIY are available here"},
 | 
			
		||||
                    {k: new Tag("service:bicycle:diy", "no"), txt: "No tools for DIY are available here"},
 | 
			
		||||
                ]
 | 
			
		||||
            }),
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        this.style = (tags) => {
 | 
			
		||||
            let icon = "assets/bike/repair_shop.svg";
 | 
			
		||||
 | 
			
		||||
            if (this.sellsBikes.matchesProperties(tags)) {
 | 
			
		||||
                icon = "assets/bike/shop.svg";
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return {
 | 
			
		||||
                color: "#ff0000",
 | 
			
		||||
                icon: L.icon({
 | 
			
		||||
                    iconUrl: icon,
 | 
			
		||||
                    iconSize: [50, 50],
 | 
			
		||||
                    iconAnchor: [25, 50]
 | 
			
		||||
                })
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
import { LayerDefinition } from "../LayerDefinition";
 | 
			
		||||
import Translations from "../../UI/i18n/Translations";
 | 
			
		||||
import { Tag } from "../../Logic/TagsFilter";
 | 
			
		||||
import {And, Tag} from "../../Logic/TagsFilter";
 | 
			
		||||
import FixedText from "../Questions/FixedText";
 | 
			
		||||
import { ImageCarouselWithUploadConstructor } from "../../UI/Image/ImageCarouselWithUpload";
 | 
			
		||||
import * as L from "leaflet";
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ export default class BikeShops extends LayerDefinition {
 | 
			
		|||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super();
 | 
			
		||||
        this.name = Translations.t.cyclofix.shop.name.txt
 | 
			
		||||
        this.name = Translations.t.cyclofix.shop.name
 | 
			
		||||
        this.icon = "./assets/bike/repair_shop.svg"
 | 
			
		||||
        this.overpassFilter = new Tag("shop", "bicycle");
 | 
			
		||||
        this.newElementTags = [
 | 
			
		||||
| 
						 | 
				
			
			@ -32,21 +32,29 @@ export default class BikeShops extends LayerDefinition {
 | 
			
		|||
        this.style = this.generateStyleFunction();
 | 
			
		||||
        this.title = new TagRenderingOptions({
 | 
			
		||||
            mappings: [
 | 
			
		||||
                {k: this.sellsBikes, txt: "Bicycle shop"},
 | 
			
		||||
                {k: new Tag("service:bicycle:retail", "no"), txt: Translations.t.cyclofix.shop.titleRepair},
 | 
			
		||||
                {k: new And([new Tag("name", "*"), this.sellsBikes]), txt: Translations.t.cyclofix.shop.titleShopNamed},
 | 
			
		||||
                {
 | 
			
		||||
                    k: new And([new Tag("name", "*"), new Tag("service:bicycle:retail", "")]),
 | 
			
		||||
                    txt: Translations.t.cyclofix.shop.titleShop
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    k: new And([new Tag("name", "*"), new Tag("service:bicycle:retail", "no")]),
 | 
			
		||||
                    txt: Translations.t.cyclofix.shop.titleRepairNamed
 | 
			
		||||
                },
 | 
			
		||||
                {k: this.sellsBikes, txt: Translations.t.cyclofix.shop.titleShop},
 | 
			
		||||
                {k: new Tag("service:bicycle:retail", " "), txt: Translations.t.cyclofix.shop.title},
 | 
			
		||||
                {k: new Tag("service:bicycle:retail", "no"), txt: Translations.t.cyclofix.shop.titleRepair},
 | 
			
		||||
            ]
 | 
			
		||||
        })
 | 
			
		||||
        
 | 
			
		||||
        this.elementsToShow = [
 | 
			
		||||
            new ImageCarouselWithUploadConstructor(),
 | 
			
		||||
            //new ParkingOperator(),
 | 
			
		||||
            new ShopName(),
 | 
			
		||||
            new ShopRetail(),
 | 
			
		||||
            new ShopRental(),
 | 
			
		||||
            new ShopRepair(),
 | 
			
		||||
            new ShopPump(),
 | 
			
		||||
            new ShopDiy(),
 | 
			
		||||
            new ShopName(),
 | 
			
		||||
            new ShopSecondHand()
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ export default class BikeStations extends LayerDefinition {
 | 
			
		|||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super();
 | 
			
		||||
        this.name = Translations.t.cyclofix.station.name.txt;
 | 
			
		||||
        this.name = Translations.t.cyclofix.station.name;
 | 
			
		||||
        this.icon = "./assets/wrench.svg";
 | 
			
		||||
 | 
			
		||||
        this.overpassFilter = new And([
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ export default class BikeStations extends LayerDefinition {
 | 
			
		|||
 | 
			
		||||
        this.minzoom = 13;
 | 
			
		||||
        this.style = this.generateStyleFunction();
 | 
			
		||||
        this.title = new FixedText(Translations.t.cyclofix.station.title.txt)
 | 
			
		||||
        this.title = new FixedText(Translations.t.cyclofix.station.title)
 | 
			
		||||
 | 
			
		||||
        this.elementsToShow = [
 | 
			
		||||
            new ImageCarouselWithUploadConstructor(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ export default class Cyclofix extends Layout {
 | 
			
		|||
            "pomp",
 | 
			
		||||
            ["en", "nl", "fr"],
 | 
			
		||||
            Translations.t.cyclofix.title,
 | 
			
		||||
            [new BikeServices(), new BikeShop(), new DrinkingWater(), new BikeParkings()],
 | 
			
		||||
            [new BikeServices(), new BikeShops(), new DrinkingWater(), new BikeParkings()],
 | 
			
		||||
            16,
 | 
			
		||||
            50.8465573,
 | 
			
		||||
            4.3516970,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,9 @@ export default class ParkingOperator extends TagRenderingOptions {
 | 
			
		|||
            question: to.question.Render(),
 | 
			
		||||
            freeform: {
 | 
			
		||||
                key: "operator",
 | 
			
		||||
                template: to.template.txt,
 | 
			
		||||
                renderTemplate: to.render.txt,
 | 
			
		||||
                placeholder: Translations.t.cyclofix.freeFormPlaceholder.txt
 | 
			
		||||
                template: to.template,
 | 
			
		||||
                renderTemplate: to.render,
 | 
			
		||||
                placeholder: Translations.t.cyclofix.freeFormPlaceholder
 | 
			
		||||
            },
 | 
			
		||||
            mappings: [
 | 
			
		||||
                {k: new Tag("operator", "KU Leuven"), txt: "KU Leuven"},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ import Translations from "../../../UI/i18n/Translations";
 | 
			
		|||
export default class ShopPump extends TagRenderingOptions {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        const key = 'service:bicycle:diy'
 | 
			
		||||
        const to = Translations.t.cylofix.shop.diy
 | 
			
		||||
        const to = Translations.t.cyclofix.shop.diy
 | 
			
		||||
        super({
 | 
			
		||||
            priority: 5,
 | 
			
		||||
            question: to.question.Render(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,14 +4,14 @@ import Translations from "../../../UI/i18n/Translations";
 | 
			
		|||
 | 
			
		||||
export default class ShopPump extends TagRenderingOptions {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        const to = Translations.t.cylofix.shop.qName
 | 
			
		||||
        const to = Translations.t.cyclofix.shop.qName
 | 
			
		||||
        super({
 | 
			
		||||
            priority: 5,
 | 
			
		||||
            question: to.question.Render(),
 | 
			
		||||
            question: to.question,
 | 
			
		||||
            freeform: {
 | 
			
		||||
                key: "name",
 | 
			
		||||
                renderTemplate: to.render.txt,
 | 
			
		||||
                template: to.template.txt
 | 
			
		||||
                renderTemplate: to.render,
 | 
			
		||||
                template: to.template
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,10 +9,10 @@ export default class ShopRental extends TagRenderingOptions {
 | 
			
		|||
        const to = Translations.t.cyclofix.shop.rental
 | 
			
		||||
        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},
 | 
			
		||||
            ]
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,12 +9,12 @@ export default class ShopRepair extends TagRenderingOptions {
 | 
			
		|||
        const to = Translations.t.cyclofix.shop.repair
 | 
			
		||||
        super({
 | 
			
		||||
            priority: 5,
 | 
			
		||||
            question: to.question.Render(),
 | 
			
		||||
            question: to.question,
 | 
			
		||||
            mappings: [
 | 
			
		||||
                {k: new Tag(key, "yes"), txt: to.yes.Render()},
 | 
			
		||||
                {k: new Tag(key, "only_sold"), txt: to.sold.Render()},
 | 
			
		||||
                {k: new Tag(key, "brand"), txt: to.brand.Render()},
 | 
			
		||||
                {k: new Tag(key, "no"), txt: to.no.Render()},
 | 
			
		||||
                {k: new Tag(key, "yes"), txt: to.yes},
 | 
			
		||||
                {k: new Tag(key, "only_sold"), txt: to.sold},
 | 
			
		||||
                {k: new Tag(key, "brand"), txt: to.brand},
 | 
			
		||||
                {k: new Tag(key, "no"), txt: to.no},
 | 
			
		||||
            ]
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,14 +6,14 @@ import Translations from "../../../UI/i18n/Translations";
 | 
			
		|||
export default class ShopPump extends TagRenderingOptions {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        const key = 'service:bicycle:second_hand'
 | 
			
		||||
        const to = Translations.t.cylofix.shop.secondHand
 | 
			
		||||
        const to = Translations.t.cyclofix.shop.secondHand
 | 
			
		||||
        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, "only"), txt: to.only.Render()},
 | 
			
		||||
                {k: new Tag(key, "yes"), txt: to.yes},
 | 
			
		||||
                {k: new Tag(key, "no"), txt: to.no},
 | 
			
		||||
                {k: new Tag(key, "only"), txt: to.only},
 | 
			
		||||
            ]
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,10 +8,10 @@ export default class StationChain extends TagRenderingOptions {
 | 
			
		|||
        const to = Translations.t.cyclofix.station.chain
 | 
			
		||||
        super({
 | 
			
		||||
            priority: 5,
 | 
			
		||||
            question: to.question.Render(),
 | 
			
		||||
            question: to.question,
 | 
			
		||||
            mappings: [
 | 
			
		||||
                {k: new Tag("service:bicycle:chain_tool", "yes"), txt: to.yes.Render()},
 | 
			
		||||
                {k: new Tag("service:bicycle:chain_tool", "no"), txt: to.no.Render()},
 | 
			
		||||
                {k: new Tag("service:bicycle:chain_tool", "yes"), txt: to.yes},
 | 
			
		||||
                {k: new Tag("service:bicycle:chain_tool", "no"), txt: to.no},
 | 
			
		||||
            ]
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,8 +18,8 @@ export default class BikeStationOperator extends TagRenderingOptions {
 | 
			
		|||
            ],
 | 
			
		||||
            freeform: {
 | 
			
		||||
                key: "operator",
 | 
			
		||||
                template: to.template.txt,
 | 
			
		||||
                renderTemplate: to.render.txt,
 | 
			
		||||
                template: to.template,
 | 
			
		||||
                renderTemplate: to.render,
 | 
			
		||||
                placeholder: "organisatie"
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,8 +28,8 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor {
 | 
			
		|||
        freeform?: {
 | 
			
		||||
            key: string;
 | 
			
		||||
            tagsPreprocessor?: (tags: any) => any;
 | 
			
		||||
            template: string;
 | 
			
		||||
            renderTemplate: string;
 | 
			
		||||
            template: string | UIElement;
 | 
			
		||||
            renderTemplate: string | UIElement;
 | 
			
		||||
            placeholder?: string | UIElement;
 | 
			
		||||
            extraTags?: TagsFilter
 | 
			
		||||
        };
 | 
			
		||||
| 
						 | 
				
			
			@ -77,8 +77,9 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor {
 | 
			
		|||
         * In the question, it'll offer a textfield
 | 
			
		||||
         */
 | 
			
		||||
        freeform?: {
 | 
			
		||||
            key: string, template: string,
 | 
			
		||||
            renderTemplate: string
 | 
			
		||||
            key: string,
 | 
			
		||||
            template: string | UIElement,
 | 
			
		||||
            renderTemplate: string | UIElement
 | 
			
		||||
            placeholder?: string | UIElement,
 | 
			
		||||
            extraTags?: TagsFilter,
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			@ -141,14 +142,13 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
    private _question: UIElement;
 | 
			
		||||
    private _mapping: { k: TagsFilter, txt: UIElement, priority?: number }[];
 | 
			
		||||
    private _renderMapping: { k: TagsFilter, txt: UIElement, priority?: number }[];
 | 
			
		||||
    private _mapping: { k: TagsFilter, txt: string | UIElement, priority?: number }[];
 | 
			
		||||
 | 
			
		||||
    private _tagsPreprocessor?: ((tags: any) => any);
 | 
			
		||||
    private _freeform: {
 | 
			
		||||
        key: string, template: string,
 | 
			
		||||
        renderTemplate: string,
 | 
			
		||||
 | 
			
		||||
        key: string, 
 | 
			
		||||
        template: string | UIElement,
 | 
			
		||||
        renderTemplate: string | UIElement,
 | 
			
		||||
        placeholder?: string | UIElement,
 | 
			
		||||
        extraTags?: TagsFilter
 | 
			
		||||
    };
 | 
			
		||||
| 
						 | 
				
			
			@ -171,8 +171,9 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
        question?: string | UIElement,
 | 
			
		||||
 | 
			
		||||
        freeform?: {
 | 
			
		||||
            key: string, template: string,
 | 
			
		||||
            renderTemplate: string
 | 
			
		||||
            key: string, 
 | 
			
		||||
            template: string | UIElement,
 | 
			
		||||
            renderTemplate: string | UIElement,
 | 
			
		||||
            placeholder?: string | UIElement,
 | 
			
		||||
            extraTags?: TagsFilter,
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			@ -205,14 +206,13 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
        };
 | 
			
		||||
        
 | 
			
		||||
        this._mapping = [];
 | 
			
		||||
        this._renderMapping = [];
 | 
			
		||||
        this._freeform = options.freeform;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        for (const choice of options.mappings ?? []) {
 | 
			
		||||
            let choiceSubbed = {
 | 
			
		||||
                k: choice.k,
 | 
			
		||||
                txt: this.ApplyTemplate(choice.txt),
 | 
			
		||||
                txt: choice.txt,
 | 
			
		||||
                priority: choice.priority
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +220,7 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
                choiceSubbed = {
 | 
			
		||||
                    k: choice.k.substituteValues(
 | 
			
		||||
                        options.tagsPreprocessor(this._source.data)),
 | 
			
		||||
                    txt: this.ApplyTemplate(choice.txt),
 | 
			
		||||
                    txt: choice.txt,
 | 
			
		||||
                    priority: choice.priority
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -278,8 +278,9 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
 | 
			
		||||
    private InputElementFor(options: {
 | 
			
		||||
        freeform?: {
 | 
			
		||||
            key: string, template: string,
 | 
			
		||||
            renderTemplate: string
 | 
			
		||||
            key: string, 
 | 
			
		||||
            template: string | UIElement,
 | 
			
		||||
            renderTemplate: string | UIElement,
 | 
			
		||||
            placeholder?: string | UIElement,
 | 
			
		||||
            extraTags?: TagsFilter,
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			@ -368,7 +369,7 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
            toString: toString
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        const prepost = freeform.template.split("$$$");
 | 
			
		||||
        const prepost = Translations.W(freeform.template).InnerRender().split("$$$");
 | 
			
		||||
        return new InputElementWrapper(prepost[0], textField, prepost[1]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -376,7 +377,7 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
    IsKnown(): boolean {
 | 
			
		||||
        const tags = TagUtils.proprtiesToKV(this._source.data);
 | 
			
		||||
 | 
			
		||||
        for (const oneOnOneElement of this._mapping.concat(this._renderMapping)) {
 | 
			
		||||
        for (const oneOnOneElement of this._mapping) {
 | 
			
		||||
            if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tags)) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -386,10 +387,9 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    private CurrentValue(): TagsFilter {
 | 
			
		||||
        console.log("Creating a current value...")
 | 
			
		||||
        const tags = TagUtils.proprtiesToKV(this._source.data);
 | 
			
		||||
 | 
			
		||||
        for (const oneOnOneElement of this._mapping.concat(this._renderMapping)) {
 | 
			
		||||
        for (const oneOnOneElement of this._mapping) {
 | 
			
		||||
            if (oneOnOneElement.k !== null && oneOnOneElement.k.matches(tags)) {
 | 
			
		||||
                return oneOnOneElement.k;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -398,7 +398,6 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
            return undefined;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.log("Got a freeform tag:", new Tag(this._freeform.key, this._source.data[this._freeform.key]))
 | 
			
		||||
        return new Tag(this._freeform.key, this._source.data[this._freeform.key]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -431,7 +430,7 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
 | 
			
		||||
        let highestScore = -100;
 | 
			
		||||
        let highestTemplate = undefined;
 | 
			
		||||
        for (const oneOnOneElement of this._mapping.concat(this._renderMapping)) {
 | 
			
		||||
        for (const oneOnOneElement of this._mapping) {
 | 
			
		||||
            if (oneOnOneElement.k == null ||
 | 
			
		||||
                oneOnOneElement.k.matches(tags)) {
 | 
			
		||||
                // We have found a matching key -> we use the template, but only if it scores better
 | 
			
		||||
| 
						 | 
				
			
			@ -457,7 +456,6 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    InnerRender(): string {
 | 
			
		||||
 | 
			
		||||
        if (this.IsQuestioning() || this._editMode.data) {
 | 
			
		||||
            // Not yet known or questioning, we have to ask a question
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -499,10 +497,13 @@ class TagRendering extends UIElement implements TagDependantUIElement {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    private ApplyTemplate(template: string | UIElement): UIElement {
 | 
			
		||||
        if (template instanceof UIElement) {
 | 
			
		||||
            return template;
 | 
			
		||||
        if(template === undefined || template === null){
 | 
			
		||||
            throw "Trying to apply a template, but the template is null/undefined"
 | 
			
		||||
        }
 | 
			
		||||
        const tags = this._tagsPreprocessor(this._source.data);
 | 
			
		||||
        if (template instanceof UIElement) {
 | 
			
		||||
            template = template.Render();
 | 
			
		||||
        }
 | 
			
		||||
        return new FixedUiElement(TagUtils.ApplyTemplate(template, tags));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,6 @@ export class UserDetails {
 | 
			
		|||
 | 
			
		||||
export class OsmConnection {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private auth = new osmAuth({
 | 
			
		||||
        oauth_consumer_key: 'hivV7ec2o49Two8g9h8Is1VIiVOgxQ1iYexCbvem',
 | 
			
		||||
        oauth_secret: 'wDBRTCem0vxD7txrg1y6p5r8nvmz8tAhET7zDASI',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,11 +41,11 @@ export class CenterMessageBox extends UIElement {
 | 
			
		|||
            return this._centermessage.data;
 | 
			
		||||
        }
 | 
			
		||||
        if (this._queryRunning.data) {
 | 
			
		||||
            return Translations.t.centerMessage.loadingData.txt;
 | 
			
		||||
            return Translations.t.centerMessage.loadingData.Render();
 | 
			
		||||
        } else if (this._zoomInMore.data) {
 | 
			
		||||
            return Translations.t.centerMessage.zoomIn.txt;
 | 
			
		||||
            return Translations.t.centerMessage.zoomIn.Render();
 | 
			
		||||
        }
 | 
			
		||||
        return Translations.t.centerMessage.ready.txt;
 | 
			
		||||
        return Translations.t.centerMessage.ready.Render();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,12 @@ import {FixedUiElement} from "../Base/FixedUiElement";
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
export default class Translations {
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        throw "Translations is static. If you want to intitialize a new translation, use the singular form"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    static t = {
 | 
			
		||||
        cyclofix: {
 | 
			
		||||
            title: new T({
 | 
			
		||||
| 
						 | 
				
			
			@ -205,8 +211,17 @@ export default class Translations {
 | 
			
		|||
            },
 | 
			
		||||
            shop: {
 | 
			
		||||
                name: new T({en: 'bike shop', nl: 'fietswinkel', fr: 'TODO: fr'}),
 | 
			
		||||
                title: new T({en: 'Bike repair/shop', nl: 'Fietswinkel/herstelling', fr: 'TODO: fr'}),
 | 
			
		||||
                titleRepair: new T({en: 'Bike shop', nl: 'Fietswinkel', fr: 'TODO: fr'}),
 | 
			
		||||
                
 | 
			
		||||
                title: new T({en: 'Bike shop', nl: 'Fietszaak', fr: 'TODO: fr'}),
 | 
			
		||||
                titleRepair: new T({en: 'Bike repair', nl: 'Fietsenmaker', fr: 'TODO: fr'}),
 | 
			
		||||
                titleShop: new T({en: 'Bike repair/shop', nl: 'Fietswinkel', fr: 'TODO: fr'}),
 | 
			
		||||
                
 | 
			
		||||
                titleNamed: new T({en: 'Bike repair/shop', nl: 'Fietszaak {name}', fr: 'TODO: fr'}),
 | 
			
		||||
                titleRepairNamed: new T({en: 'Bike shop', nl: 'Fietsenmaker {name}', fr: 'TODO: fr'}),
 | 
			
		||||
                titleShopNamed: new T({en: 'Bike repair/shop', nl: 'Fietswinkel {name}', fr: 'TODO: fr'}),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                retail: {
 | 
			
		||||
                    question: new T({
 | 
			
		||||
                        en: 'Does this shop sell bikes?',
 | 
			
		||||
| 
						 | 
				
			
			@ -266,9 +281,9 @@ export default class Translations {
 | 
			
		|||
                    })
 | 
			
		||||
                },
 | 
			
		||||
                qName: {
 | 
			
		||||
                    question: new T({en: 'What is the name of this bicycle shop?', nl: 'Wat is de naam van deze fietswinkel?', fr: 'TODO: fr'}),
 | 
			
		||||
                    render: new T({en: 'This bicycle shop is called {name}', nl: 'Deze fietswinkel heet {name}', fr: 'TODO: fr'}),
 | 
			
		||||
                    template: new T({en: 'This bicycle shop is called: $$$', nl: 'Deze fietswinkel heet: $$$', fr: 'TODO: fr'})
 | 
			
		||||
                    question: new T({en: 'What is the name of this bicycle shop?', nl: 'Wat is de naam van deze fietszaak?', fr: 'TODO: fr'}),
 | 
			
		||||
                    render: new T({en: 'This bicycle shop is called {name}', nl: 'Deze fietszaak heet <b>{name}</b>', fr: 'TODO: fr'}),
 | 
			
		||||
                    template: new T({en: 'This bicycle shop is called: $$$', nl: 'Deze fietszaak heet: <b>$$$</b>', fr: 'TODO: fr'})
 | 
			
		||||
                },
 | 
			
		||||
                secondHand: {
 | 
			
		||||
                    question: new T({en: 'Does this shop sell second-hand bikes?', nl: 'Verkoopt deze winkel tweedehands fietsen?', fr: 'TODO: fr'}),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										23
									
								
								test.ts
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								test.ts
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2,12 +2,31 @@ import {DropDown} from "./UI/Input/DropDown";
 | 
			
		|||
import Locale from "./UI/i18n/Locale";
 | 
			
		||||
import Combine from "./UI/Base/Combine";
 | 
			
		||||
import Translations from "./UI/i18n/Translations";
 | 
			
		||||
import {TagRenderingOptions} from "./Customizations/TagRendering";
 | 
			
		||||
import {UIEventSource} from "./UI/UIEventSource";
 | 
			
		||||
import {Tag} from "./Logic/TagsFilter";
 | 
			
		||||
import {Changes} from "./Logic/Changes";
 | 
			
		||||
import {OsmConnection} from "./Logic/OsmConnection";
 | 
			
		||||
import Translation from "./UI/i18n/Translation";
 | 
			
		||||
 | 
			
		||||
console.log("Hello world")
 | 
			
		||||
 | 
			
		||||
Locale.language.setData("en");
 | 
			
		||||
let languagePicker = new DropDown("", ["en", "nl"].map(lang => {
 | 
			
		||||
        return {value: lang, shown: lang}
 | 
			
		||||
    }
 | 
			
		||||
), Locale.language).AttachTo("maindiv");
 | 
			
		||||
 | 
			
		||||
new Combine(["abc",Translations.t.cyclofix.title, Translations.t.cyclofix.title]).AttachTo("extradiv");
 | 
			
		||||
 | 
			
		||||
let tags = new UIEventSource({
 | 
			
		||||
    x:"y"
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
new TagRenderingOptions({
 | 
			
		||||
    mappings: [{k: new Tag("x","y"), txt: new Translation({en: "ENG", nl: "NED"})}]
 | 
			
		||||
}).construct({
 | 
			
		||||
    tags: tags,
 | 
			
		||||
    changes: new Changes(
 | 
			
		||||
        "cs",
 | 
			
		||||
        new OsmConnection(true)
 | 
			
		||||
    )
 | 
			
		||||
}).AttachTo("extradiv")
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue