This RFC is for gathering input on the question how units for quantities should be represented in the user interface, where the information needed for that should come from, and how unit input during editing should work.
The status quo is:
- Quantity values use an arbitrary string to identify the unit of the quantity ("no unit" is represented as "1")
- Wikibase restricts units to HTTP(S) URIs.
The intention is to allow any Wikidata Items as a unit on Wikidata. Third party installations should be free to:
- use Wikidata (!) Items
- use some other vocabulary for Units, like QUDT (as a fixed list in the config).
When formatting quantities with units, we need (at least) two options:
- use the full, localized name of the unit ("meter", "ounce")
- use the unit symbol ("m", "oz"). These also need to be localizable (e.g. Russian uses км/ч for km/h).
When using Wikidata items, we could use the item's label for the "full" name, and P558 for specifying the "symbol" - but P558 has type "string", so it's not localizable. We would need a multilingual text property. Also, we would have to base this functionality on a user defined property, which seems a bit brittle.
QuantityValueFormatter will need an option that controls if and how the unit is shown. Another option will be needed for unit conversion later.
When inputting a unit, we need to consider (at least) the two modes i mentioned above (Wikidata item or fixed list from config). It would probably be fine to only implement the case we need for Wikidata right now, but it would be great if that would be usable by third party installs. This means, I think:
- Include an EntitySelector in the ValueView for Quanity values (The EntitySelector should pick Wikidata items, not local entities, on third party installs)
- Make the EntitySelector generate full URIs based on the selected entity
- Pass the URI from the Unit/EntitySelector to parsevalue as an option (just like we do for the reference globe calendar)
- Make QuantityValueParser use units passed as options. Make parsing of "inline units" optional (or remove it).
The text in the EntitySelector would primarily be the entity label, as usual. However, it would be nice if we could show the unit symbol (see above) alongside the label. It would also be nice to have some indication about whether a unit is convertible or not (i.e. if it's a "standard" unit).