Open
Description
Currently, :unit
suffers from many of the same problems as, for example, u:locale
, explained in #1006.
Since the unit being formatted is provided by the Measure
input type (which I think is a good decision), the message formatter cannot know ahead of time which units are being formatted, so it needs to pessimistically link the data for all possible units. Unit display names are among the largest chunks of data, so requiring this behavior is a non-starter for ICU4X.
A few ways to mitigate this:
- Add the quantity to the unit function, such as
:unit:length
, as suggested by @eemeli. This would allow ICU4X to link only a smaller subset of units, which should be generally small enough to be manageable. - Require the quantity or the unit to be specified in the message. For example,
:unit unit=meter
with a Number input is OK, as is:unit quantity=length
with a Measure unit. - Require a unit to be specified in the message, but allow the unit to be overridden by Measure so long as the quantity matches. For example,
:unit unit=meter
can be formatted with a Measure carryingfoot
but not a Measure carryinggallon
. - Require the context to be specified in the message, and tweak how context works.
:unit context=length
would not do conversion, but conversion would happen with:unit context=length-road
.