forked from MapComplete/MapComplete
Add singular forms for units
This commit is contained in:
parent
c9ba7a8d44
commit
feeca1de46
9 changed files with 338 additions and 95 deletions
|
@ -2,7 +2,7 @@ import {Utils} from "../Utils";
|
||||||
|
|
||||||
export default class Constants {
|
export default class Constants {
|
||||||
|
|
||||||
public static vNumber = "0.9.10";
|
public static vNumber = "0.9.11";
|
||||||
|
|
||||||
// The user journey states thresholds when a new feature gets unlocked
|
// The user journey states thresholds when a new feature gets unlocked
|
||||||
public static userJourney = {
|
public static userJourney = {
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
import {Translation} from "../UI/i18n/Translation";
|
import {Translation} from "../UI/i18n/Translation";
|
||||||
import {ApplicableUnitJson} from "./ThemeConfig/Json/UnitConfigJson";
|
import {ApplicableUnitJson} from "./ThemeConfig/Json/UnitConfigJson";
|
||||||
import Translations from "../UI/i18n/Translations";
|
import Translations from "../UI/i18n/Translations";
|
||||||
|
import {UIEventSource} from "../Logic/UIEventSource";
|
||||||
|
import BaseUIElement from "../UI/BaseUIElement";
|
||||||
|
import Toggle from "../UI/Input/Toggle";
|
||||||
|
|
||||||
export class Denomination {
|
export class Denomination {
|
||||||
public readonly canonical: string;
|
public readonly canonical: string;
|
||||||
readonly default: boolean;
|
public readonly _canonicalSingular: string;
|
||||||
readonly prefix: boolean;
|
public readonly default: boolean;
|
||||||
|
public readonly prefix: boolean;
|
||||||
public readonly alternativeDenominations: string [];
|
public readonly alternativeDenominations: string [];
|
||||||
private readonly _human: Translation;
|
private readonly _human: Translation;
|
||||||
|
private readonly _humanSingular?: Translation;
|
||||||
|
|
||||||
|
|
||||||
constructor(json: ApplicableUnitJson, context: string) {
|
constructor(json: ApplicableUnitJson, context: string) {
|
||||||
context = `${context}.unit(${json.canonicalDenomination})`
|
context = `${context}.unit(${json.canonicalDenomination})`
|
||||||
|
@ -15,6 +21,8 @@ export class Denomination {
|
||||||
if (this.canonical === undefined) {
|
if (this.canonical === undefined) {
|
||||||
throw `${context}: this unit has no decent canonical value defined`
|
throw `${context}: this unit has no decent canonical value defined`
|
||||||
}
|
}
|
||||||
|
this._canonicalSingular = json.canonicalDenominationSingular?.trim()
|
||||||
|
|
||||||
|
|
||||||
json.alternativeDenomination.forEach((v, i) => {
|
json.alternativeDenomination.forEach((v, i) => {
|
||||||
if (((v?.trim() ?? "") === "")) {
|
if (((v?.trim() ?? "") === "")) {
|
||||||
|
@ -27,6 +35,7 @@ export class Denomination {
|
||||||
this.default = json.default ?? false;
|
this.default = json.default ?? false;
|
||||||
|
|
||||||
this._human = Translations.T(json.human, context + "human")
|
this._human = Translations.T(json.human, context + "human")
|
||||||
|
this._humanSingular = Translations.T(json.humanSingular, context + "humanSingular")
|
||||||
|
|
||||||
this.prefix = json.prefix ?? false;
|
this.prefix = json.prefix ?? false;
|
||||||
|
|
||||||
|
@ -35,7 +44,22 @@ export class Denomination {
|
||||||
get human(): Translation {
|
get human(): Translation {
|
||||||
return this._human.Clone()
|
return this._human.Clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get humanSingular(): Translation {
|
||||||
|
return (this._humanSingular ?? this._human).Clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
getToggledHuman(isSingular: UIEventSource<boolean>): BaseUIElement{
|
||||||
|
if(this._humanSingular === undefined){
|
||||||
|
return this.human
|
||||||
|
}
|
||||||
|
return new Toggle(
|
||||||
|
this.humanSingular,
|
||||||
|
this.human,
|
||||||
|
isSingular
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
public canonicalValue(value: string, actAsDefault?: boolean) {
|
public canonicalValue(value: string, actAsDefault?: boolean) {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -44,9 +68,12 @@ export class Denomination {
|
||||||
if (stripped === null) {
|
if (stripped === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (stripped + " " + this.canonical.trim()).trim();
|
if(stripped === "1" && this._canonicalSingular !== undefined){
|
||||||
|
return "1 "+this._canonicalSingular
|
||||||
|
}
|
||||||
|
return stripped + " " + this.canonical;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the core value (without unit) if:
|
* Returns the core value (without unit) if:
|
||||||
* - the value ends with the canonical or an alternative value (or begins with if prefix is set)
|
* - the value ends with the canonical or an alternative value (or begins with if prefix is set)
|
||||||
|
@ -61,26 +88,36 @@ export class Denomination {
|
||||||
}
|
}
|
||||||
|
|
||||||
value = value.toLowerCase()
|
value = value.toLowerCase()
|
||||||
if (this.prefix) {
|
const self = this;
|
||||||
if (value.startsWith(this.canonical) && this.canonical !== "") {
|
function startsWith(key){
|
||||||
return value.substring(this.canonical.length).trim();
|
if(self.prefix){
|
||||||
}
|
return value.startsWith(key)
|
||||||
for (const alternativeValue of this.alternativeDenominations) {
|
}else{
|
||||||
if (value.startsWith(alternativeValue)) {
|
return value.endsWith(key)
|
||||||
return value.substring(alternativeValue.length).trim();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
function substr(key){
|
||||||
if (value.endsWith(this.canonical.toLowerCase()) && this.canonical !== "") {
|
if(self.prefix){
|
||||||
return value.substring(0, value.length - this.canonical.length).trim();
|
return value.substr(key.length).trim()
|
||||||
}
|
}else{
|
||||||
for (const alternativeValue of this.alternativeDenominations) {
|
return value.substring(0, value.length - key.length).trim()
|
||||||
if (value.endsWith(alternativeValue.toLowerCase())) {
|
}
|
||||||
return value.substring(0, value.length - alternativeValue.length).trim();
|
}
|
||||||
}
|
|
||||||
|
if(this.canonical !== "" && startsWith(this.canonical.toLowerCase())){
|
||||||
|
return substr(this.canonical)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this._canonicalSingular !== undefined && this._canonicalSingular !== "" && startsWith(this._canonicalSingular)){
|
||||||
|
return substr(this._canonicalSingular)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const alternativeValue of this.alternativeDenominations) {
|
||||||
|
if (startsWith(alternativeValue)) {
|
||||||
|
return substr(alternativeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.default || actAsDefault) {
|
if (this.default || actAsDefault) {
|
||||||
const parsed = Number(value.trim())
|
const parsed = Number(value.trim())
|
||||||
|
|
|
@ -24,7 +24,12 @@ export interface ApplicableUnitJson
|
||||||
* If the user inputs '42', the canonical value will be added and it'll become '42m'
|
* If the user inputs '42', the canonical value will be added and it'll become '42m'
|
||||||
*/
|
*/
|
||||||
canonicalDenomination: string,
|
canonicalDenomination: string,
|
||||||
|
/**
|
||||||
|
* The canonical denomination in the case that the unit is precisely '1'
|
||||||
|
*/
|
||||||
|
canonicalDenominationSingular?: string,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of alternative values which can occur in the OSM database - used for parsing.
|
* A list of alternative values which can occur in the OSM database - used for parsing.
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +44,15 @@ export interface ApplicableUnitJson
|
||||||
*/
|
*/
|
||||||
human?: string | any
|
human?: string | any
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for humans in the dropdown. This should not use abbreviations and should be translated, e.g.
|
||||||
|
* {
|
||||||
|
* "en": "minute",
|
||||||
|
* "nl": "minuut"x²
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
humanSingular?: string | any
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set, then the canonical value will be prefixed instead, e.g. for '€'
|
* If set, then the canonical value will be prefixed instead, e.g. for '€'
|
||||||
* Note that if all values use 'prefix', the dropdown might move to before the text field
|
* Note that if all values use 'prefix', the dropdown might move to before the text field
|
||||||
|
|
|
@ -34,10 +34,10 @@ export class Unit {
|
||||||
this.denominationsSorted = [...this.denominations]
|
this.denominationsSorted = [...this.denominations]
|
||||||
this.denominationsSorted.sort((a, b) => b.canonical.length - a.canonical.length)
|
this.denominationsSorted.sort((a, b) => b.canonical.length - a.canonical.length)
|
||||||
|
|
||||||
|
|
||||||
const possiblePostFixes = new Set<string>()
|
const possiblePostFixes = new Set<string>()
|
||||||
|
|
||||||
function addPostfixesOf(str) {
|
function addPostfixesOf(str) {
|
||||||
|
if(str === undefined){return}
|
||||||
str = str.toLowerCase()
|
str = str.toLowerCase()
|
||||||
for (let i = 0; i < str.length + 1; i++) {
|
for (let i = 0; i < str.length + 1; i++) {
|
||||||
const substr = str.substring(0, i)
|
const substr = str.substring(0, i)
|
||||||
|
@ -47,6 +47,7 @@ export class Unit {
|
||||||
|
|
||||||
for (const denomination of this.denominations) {
|
for (const denomination of this.denominations) {
|
||||||
addPostfixesOf(denomination.canonical)
|
addPostfixesOf(denomination.canonical)
|
||||||
|
addPostfixesOf(denomination._canonicalSingular)
|
||||||
denomination.alternativeDenominations.forEach(addPostfixesOf)
|
denomination.alternativeDenominations.forEach(addPostfixesOf)
|
||||||
}
|
}
|
||||||
this.possiblePostFixes = Array.from(possiblePostFixes)
|
this.possiblePostFixes = Array.from(possiblePostFixes)
|
||||||
|
@ -111,7 +112,7 @@ export class Unit {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const [stripped, denom] = this.findDenomination(value)
|
const [stripped, denom] = this.findDenomination(value)
|
||||||
const human = denom?.human
|
const human = stripped === "1" ? denom?.humanSingular : denom?.human
|
||||||
if (human === undefined) {
|
if (human === undefined) {
|
||||||
return new FixedUiElement(stripped ?? value);
|
return new FixedUiElement(stripped ?? value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,14 +361,17 @@ export default class ValidatedTextField {
|
||||||
// This implies:
|
// This implies:
|
||||||
// We have to create a dropdown with applicable denominations, and fuse those values
|
// We have to create a dropdown with applicable denominations, and fuse those values
|
||||||
const unit = options.unit
|
const unit = options.unit
|
||||||
|
|
||||||
|
|
||||||
|
const isSingular = input.GetValue().map(str => str?.trim() === "1")
|
||||||
|
|
||||||
const unitDropDown =
|
const unitDropDown =
|
||||||
unit.denominations.length === 1 ?
|
unit.denominations.length === 1 ?
|
||||||
new FixedInputElement(unit.denominations[0].human, unit.denominations[0])
|
new FixedInputElement( unit.denominations[0].getToggledHuman(isSingular), unit.denominations[0])
|
||||||
: new DropDown("",
|
: new DropDown("",
|
||||||
unit.denominations.map(denom => {
|
unit.denominations.map(denom => {
|
||||||
return {
|
return {
|
||||||
shown: denom.human,
|
shown: denom.getToggledHuman(isSingular),
|
||||||
value: denom
|
value: denom
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -370,7 +370,8 @@ export default class SpecialVisualizations {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
const unit = state.layoutToUse.data.units.filter(unit => unit.isApplicableToKey(key))[0]
|
const allUnits = [].concat(...state.layoutToUse.data.layers.map(lyr => lyr.units))
|
||||||
|
const unit = allUnits.filter(unit => unit.isApplicableToKey(key))[0]
|
||||||
if (unit === undefined) {
|
if (unit === undefined) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,8 +344,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b><b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)</b> <img style='width:1rem;' src='./assets/layers/charging_station/CEE7_4F.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b><b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)</b> <img style='width:1rem;' src='./assets/layers/charging_station/CEE7_4F.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Schuko wall plug</b> without ground pin (CEE7/4 type F)</b> <img style='width:1rem;' src='./assets/layers/charging_station/CEE7_4F.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Schuko wall plug</b> without ground pin (CEE7/4 type F)</b> <img style='width:1rem;' src='./assets/layers/charging_station/CEE7_4F.svg'/> plugs of type <b>Schuko wall plug</b> without ground pin (CEE7/4 type F) available here",
|
||||||
"nl": "Hier zijn <b><b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)</b> <img style='width:1rem;' src='./assets/layers/charging_station/CEE7_4F.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b><b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)</b> <img style='width:1rem;' src='./assets/layers/charging_station/CEE7_4F.svg'/> stekkers van het type <b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)"
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:schuko",
|
"key": "socket:schuko",
|
||||||
|
@ -451,8 +451,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b><b>Europese stekker</b> met aardingspin (CEE7/4 type E)</b> <img style='width:1rem;' src='./assets/layers/charging_station/TypeE.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b><b>Europese stekker</b> met aardingspin (CEE7/4 type E)</b> <img style='width:1rem;' src='./assets/layers/charging_station/TypeE.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>European wall plug</b> with ground pin (CEE7/4 type E)</b> <img style='width:1rem;' src='./assets/layers/charging_station/TypeE.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>European wall plug</b> with ground pin (CEE7/4 type E)</b> <img style='width:1rem;' src='./assets/layers/charging_station/TypeE.svg'/> plugs of type <b>European wall plug</b> with ground pin (CEE7/4 type E) available here",
|
||||||
"nl": "Hier zijn <b><b>Europese stekker</b> met aardingspin (CEE7/4 type E)</b> <img style='width:1rem;' src='./assets/layers/charging_station/TypeE.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b><b>Europese stekker</b> met aardingspin (CEE7/4 type E)</b> <img style='width:1rem;' src='./assets/layers/charging_station/TypeE.svg'/> stekkers van het type <b>Europese stekker</b> met aardingspin (CEE7/4 type E)"
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:typee",
|
"key": "socket:typee",
|
||||||
|
@ -565,8 +565,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Chademo_type4.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Chademo_type4.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Chademo</b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Chademo_type4.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Chademo</b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Chademo_type4.svg'/> plugs of type <b>Chademo</b> available here",
|
||||||
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Chademo_type4.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Chademo_type4.svg'/> stekkers van het type "
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:chademo",
|
"key": "socket:chademo",
|
||||||
|
@ -672,8 +672,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b><b>Type 1 met kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b><b>Type 1 met kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Type 1 with cable</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Type 1 with cable</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type <b>Type 1 with cable</b> (J1772) available here",
|
||||||
"nl": "Hier zijn <b><b>Type 1 met kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b><b>Type 1 met kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> stekkers van het type <b>Type 1 met kabel</b> (J1772)"
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:type1_cable",
|
"key": "socket:type1_cable",
|
||||||
|
@ -793,8 +793,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b><b>Type 1 <i>zonder</i> kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b><b>Type 1 <i>zonder</i> kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Type 1 <i>without</i> cable</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Type 1 <i>without</i> cable</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type <b>Type 1 <i>without</i> cable</b> (J1772) available here",
|
||||||
"nl": "Hier zijn <b><b>Type 1 <i>zonder</i> kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b><b>Type 1 <i>zonder</i> kabel</b> (J1772)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1_J1772.svg'/> stekkers van het type <b>Type 1 <i>zonder</i> kabel</b> (J1772)"
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:type1",
|
"key": "socket:type1",
|
||||||
|
@ -928,8 +928,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1-ccs.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1-ccs.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Type 1 CCS</b> (aka Type 1 Combo)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1-ccs.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Type 1 CCS</b> (aka Type 1 Combo)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1-ccs.svg'/> plugs of type <b>Type 1 CCS</b> (aka Type 1 Combo) available here",
|
||||||
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1-ccs.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type1-ccs.svg'/> stekkers van het type "
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:type1_combo",
|
"key": "socket:type1_combo",
|
||||||
|
@ -1070,8 +1070,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Tesla Supercharger</b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Tesla Supercharger</b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> plugs of type <b>Tesla Supercharger</b> available here",
|
||||||
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> stekkers van het type "
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:tesla_supercharger",
|
"key": "socket:tesla_supercharger",
|
||||||
|
@ -1198,8 +1198,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_socket.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_socket.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Type 2</b> (mennekes)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_socket.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Type 2</b> (mennekes)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_socket.svg'/> plugs of type <b>Type 2</b> (mennekes) available here",
|
||||||
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_socket.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_socket.svg'/> stekkers van het type "
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:type2",
|
"key": "socket:type2",
|
||||||
|
@ -1326,8 +1326,8 @@
|
||||||
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_CCS.svg'/> heeft dit oplaadpunt?"
|
"nl": "Hoeveel stekkers van type <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_CCS.svg'/> heeft dit oplaadpunt?"
|
||||||
},
|
},
|
||||||
"render": {
|
"render": {
|
||||||
"en": "There are <b><b>Type 2 CCS</b> (mennekes)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_CCS.svg'/> plugs of type [object Map] available here",
|
"en": "There are <b><b>Type 2 CCS</b> (mennekes)</b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_CCS.svg'/> plugs of type <b>Type 2 CCS</b> (mennekes) available here",
|
||||||
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_CCS.svg'/> stekkers van het type [object Map]"
|
"nl": "Hier zijn <b></b> <img style='width:1rem;' src='./assets/layers/charging_station/Type2_CCS.svg'/> stekkers van het type "
|
||||||
},
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "socket:type2_combo",
|
"key": "socket:type2_combo",
|
||||||
|
@ -1441,52 +1441,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"#": "fee/charge",
|
|
||||||
"question": {
|
|
||||||
"en": "How much does one have to pay to use this charging station?",
|
|
||||||
"nl": "Hoeveel kost het gebruik van dit oplaadpunt?"
|
|
||||||
},
|
|
||||||
"freeform": {
|
|
||||||
"key": "charge",
|
|
||||||
"addExtraTags": [
|
|
||||||
"fee=yes"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"render": {
|
|
||||||
"en": "Using this charging station costs <b>{charge}</b>",
|
|
||||||
"nl": "Dit oplaadpunt gebruiken kost <b>{charge}</b>"
|
|
||||||
},
|
|
||||||
"mappings": [
|
|
||||||
{
|
|
||||||
"if": {
|
|
||||||
"and": [
|
|
||||||
"fee=no",
|
|
||||||
"charge="
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"nl": "Gratis te gebruiken",
|
|
||||||
"en": "Free to use"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"builtin": "payment-options",
|
|
||||||
"override": {
|
|
||||||
"mappings+": [
|
|
||||||
{
|
|
||||||
"if": "payment:app=yes",
|
|
||||||
"ifnot": "payment:app=no",
|
|
||||||
"then": {
|
|
||||||
"en": "Payment is done using a dedicated app",
|
|
||||||
"nl": "Betalen via een app van het netwerk"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"#": "Authentication",
|
"#": "Authentication",
|
||||||
"question": {
|
"question": {
|
||||||
|
@ -1624,6 +1578,81 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"#": "fee/charge",
|
||||||
|
"question": {
|
||||||
|
"en": "How much does one have to pay to use this charging station?",
|
||||||
|
"nl": "Hoeveel kost het gebruik van dit oplaadpunt?"
|
||||||
|
},
|
||||||
|
"freeform": {
|
||||||
|
"key": "charge",
|
||||||
|
"addExtraTags": [
|
||||||
|
"fee=yes"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"render": {
|
||||||
|
"en": "Using this charging station costs <b>{charge}</b>",
|
||||||
|
"nl": "Dit oplaadpunt gebruiken kost <b>{charge}</b>"
|
||||||
|
},
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"if": {
|
||||||
|
"and": [
|
||||||
|
"fee=no",
|
||||||
|
"charge="
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"nl": "Gratis te gebruiken",
|
||||||
|
"en": "Free to use"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"builtin": "payment-options",
|
||||||
|
"override": {
|
||||||
|
"condition": {
|
||||||
|
"or": [
|
||||||
|
"fee=yes",
|
||||||
|
"charge~*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mappings+": [
|
||||||
|
{
|
||||||
|
"if": "payment:app=yes",
|
||||||
|
"ifnot": "payment:app=no",
|
||||||
|
"then": {
|
||||||
|
"en": "Payment is done using a dedicated app",
|
||||||
|
"nl": "Betalen via een app van het netwerk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"#": "maxstay",
|
||||||
|
"question": {
|
||||||
|
"en": "What is the maximum amount of time one is allowed to stay here?",
|
||||||
|
"nl": "Hoelang mag een voertuig hier blijven staan?"
|
||||||
|
},
|
||||||
|
"freeform": {
|
||||||
|
"key": "maxstay"
|
||||||
|
},
|
||||||
|
"render": {
|
||||||
|
"en": "One can stay at most <b>{canonical(maxstay)}</b>",
|
||||||
|
"nl": "De maximale parkeertijd hier is <b>{canonical(maxstay)}</b>"
|
||||||
|
},
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"if": "maxstay=unlimited",
|
||||||
|
"then": {
|
||||||
|
"en": "No timelimit on leaving your vehicle here",
|
||||||
|
"nl": "Geen maximum parkeertijd"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"#": "Network",
|
"#": "Network",
|
||||||
"render": {
|
"render": {
|
||||||
|
@ -1992,6 +2021,69 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"units": [
|
"units": [
|
||||||
|
{
|
||||||
|
"appliesToKey": [
|
||||||
|
"maxstay"
|
||||||
|
],
|
||||||
|
"applicableUnits": [
|
||||||
|
{
|
||||||
|
"canonicalDenomination": "minutes",
|
||||||
|
"canonicalDenominationSingular": "minute",
|
||||||
|
"alternativeDenomination": [
|
||||||
|
"m",
|
||||||
|
"min",
|
||||||
|
"mins",
|
||||||
|
"minuten",
|
||||||
|
"mns"
|
||||||
|
],
|
||||||
|
"human": {
|
||||||
|
"en": " minutes",
|
||||||
|
"nl": " minuten"
|
||||||
|
},
|
||||||
|
"humanSingular": {
|
||||||
|
"en": " minute",
|
||||||
|
"nl": " minuut"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"canonicalDenomination": "hours",
|
||||||
|
"canonicalDenominationSingular": "hour",
|
||||||
|
"alternativeDenomination": [
|
||||||
|
"h",
|
||||||
|
"hrs",
|
||||||
|
"hours",
|
||||||
|
"u",
|
||||||
|
"uur",
|
||||||
|
"uren"
|
||||||
|
],
|
||||||
|
"human": {
|
||||||
|
"en": " hours",
|
||||||
|
"nl": " uren"
|
||||||
|
},
|
||||||
|
"humanSingular": {
|
||||||
|
"en": " hour",
|
||||||
|
"nl": " uur"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"canonicalDenomination": "days",
|
||||||
|
"canonicalDenominationSingular": "day",
|
||||||
|
"alternativeDenomination": [
|
||||||
|
"dys",
|
||||||
|
"dagen",
|
||||||
|
"dag"
|
||||||
|
],
|
||||||
|
"human": {
|
||||||
|
"en": " days",
|
||||||
|
"nl": " day"
|
||||||
|
},
|
||||||
|
"humanSingular": {
|
||||||
|
"en": " day",
|
||||||
|
"nl": " dag"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"appliesToKey": [
|
"appliesToKey": [
|
||||||
"socket:schuko:voltage",
|
"socket:schuko:voltage",
|
||||||
|
|
|
@ -331,6 +331,29 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"#": "maxstay",
|
||||||
|
"question": {
|
||||||
|
"en": "What is the maximum amount of time one is allowed to stay here?",
|
||||||
|
"nl": "Hoelang mag een voertuig hier blijven staan?"
|
||||||
|
},
|
||||||
|
"freeform": {
|
||||||
|
"key": "maxstay"
|
||||||
|
},
|
||||||
|
"render": {
|
||||||
|
"en": "One can stay at most <b>{canonical(maxstay)}</b>",
|
||||||
|
"nl": "De maximale parkeertijd hier is <b>{canonical(maxstay)}</b>"
|
||||||
|
},
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"if": "maxstay=unlimited",
|
||||||
|
"then": {
|
||||||
|
"en": "No timelimit on leaving your vehicle here",
|
||||||
|
"nl": "Geen maximum parkeertijd"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"#": "Network",
|
"#": "Network",
|
||||||
"render": {
|
"render": {
|
||||||
|
@ -624,5 +647,70 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"units": [
|
||||||
|
{
|
||||||
|
"appliesToKey": [
|
||||||
|
"maxstay"
|
||||||
|
],
|
||||||
|
"applicableUnits": [
|
||||||
|
{
|
||||||
|
"canonicalDenomination": "minutes",
|
||||||
|
"canonicalDenominationSingular": "minute",
|
||||||
|
"alternativeDenomination": [
|
||||||
|
"m",
|
||||||
|
"min",
|
||||||
|
"mins",
|
||||||
|
"minuten",
|
||||||
|
"mns"
|
||||||
|
],
|
||||||
|
"human": {
|
||||||
|
"en": " minutes",
|
||||||
|
"nl": " minuten"
|
||||||
|
},
|
||||||
|
"humanSingular": {
|
||||||
|
"en": " minute",
|
||||||
|
"nl": " minuut"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"canonicalDenomination": "hours",
|
||||||
|
"canonicalDenominationSingular": "hour",
|
||||||
|
"alternativeDenomination": [
|
||||||
|
"h",
|
||||||
|
"hrs",
|
||||||
|
"hours",
|
||||||
|
"u",
|
||||||
|
"uur",
|
||||||
|
"uren"
|
||||||
|
],
|
||||||
|
"human": {
|
||||||
|
"en": " hours",
|
||||||
|
"nl": " uren"
|
||||||
|
},
|
||||||
|
"humanSingular": {
|
||||||
|
"en": " hour",
|
||||||
|
"nl": " uur"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"canonicalDenomination": "days",
|
||||||
|
"canonicalDenominationSingular": "day",
|
||||||
|
"alternativeDenomination": [
|
||||||
|
"dys",
|
||||||
|
"dagen",
|
||||||
|
"dag"
|
||||||
|
],
|
||||||
|
"human": {
|
||||||
|
"en": " days",
|
||||||
|
"nl": " day"
|
||||||
|
},
|
||||||
|
"humanSingular":{
|
||||||
|
"en": " day",
|
||||||
|
"nl": " dag"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,9 @@ function run(file, protojson) {
|
||||||
options: filterOptions
|
options: filterOptions
|
||||||
})
|
})
|
||||||
|
|
||||||
proto["units"] = [
|
|
||||||
|
|
||||||
|
const extraUnits = [
|
||||||
{
|
{
|
||||||
appliesToKey: entries.map(e => e.key + ":voltage"),
|
appliesToKey: entries.map(e => e.key + ":voltage"),
|
||||||
applicableUnits: [{
|
applicableUnits: [{
|
||||||
|
@ -267,6 +269,11 @@ function run(file, protojson) {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if(proto["units"] == undefined){
|
||||||
|
proto["units"] = []
|
||||||
|
}
|
||||||
|
proto["units"].push(...extraUnits)
|
||||||
|
|
||||||
writeFileSync("charging_station.json", JSON.stringify(proto, undefined, " "))
|
writeFileSync("charging_station.json", JSON.stringify(proto, undefined, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue