Skip to content

:unit needs to support data slicing #1079

Open
@sffc

Description

@sffc

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:

  1. 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.
  2. 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.
  3. 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 carrying foot but not a Measure carrying gallon.
  4. 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.

CC @macchiati @Manishearth

Metadata

Metadata

Assignees

No one assigned

    Labels

    LDML48LDML48 ReleasefunctionsIssue pertains to the default function set

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions