Skip to content

Conversation

@k-yle
Copy link
Collaborator

@k-yle k-yle commented May 6, 2025

Closes #15

Here's a concrete proposal for the measurement field. Every measurement field needs to define dimension, usage, and units. See discussion in #15.

For units, the keys are the IDs used by CLDR. The value(s) are the the units that are used in the OSM tag.

{
    "key": "maxspeed",
    "label": "Speed Limit",
    "placeholder": "40, 50, 60...",

    "type": "measurement",
    "measurement": {
        "dimension": "speed",
        "usage": "default",
        "units": {
            "kilometer-per-hour": [""],
            "mile-per-hour": ["mph"],
            "knot": ["kt", "kn"]
        }
    }
}

This implementation is a bit complicated because:

  • we want the json schema to validate that dimension, usage, and the keys of units are valid, using cldr-core
  • when fetching translations from transifex, we need to merge the translations with CLDR's translations, for the units that we use, using cldr-units-full.

The generated dist/translations/*.json files now contain a new property called units:

  // es.min.json
  {
    "presets": { … },
+   "units": {
+     "speed": {
+       "kilometer-per-hour": { "long": "kilómetros por hora",  "narrow": "km/h" },
+       "mile-per-hour": { "long": "millas por hora", "narrow": "mi/h" },
+       "knot": { "long": "nudos", "narrow": "kn" }
+     }
+   }
  }

The PR does not implement any logic to extract the default values per region, because it's not yet clear where this data should be stored.

@k-yle k-yle force-pushed the kh/measurement branch from 621f4d6 to 1a29aec Compare May 6, 2025 10:43
@k-yle
Copy link
Collaborator Author

k-yle commented May 6, 2025

auto-complete & validation works nicely, at the expense of complicating the code in this package:

Screen.Recording.2025-05-06.at.20.39.47.mov

@k-yle
Copy link
Collaborator Author

k-yle commented Oct 24, 2025

conflicts resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking javascript Pull requests that update javascript code json-schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add measurement field type

4 participants