Description
During the February meetings, we ended up leaving out the :number
style
values currency
and unit
, and their related options: currency
, currencyDisplay
, currencySign
, unit
, unitDisplay
.
Furthermore, we also include this direction in the spec:
Implementations SHOULD avoid creating options that conflict with these, but are encouraged to track development of these options during Tech Preview.
We should work towards supporting currency and unit formatting in MF2; hence this issue. Looking back to the discussions (also #621) on this topic, it would be good to get input on the parameters of an acceptable solution. To that end, I'm adding assignees here who have been vocal on the topic previously; also CC @ryzokuken.
To get us started, I propose that we re-add all the options currently left out of the tech preview, except for currency
and unit
. This would mean that in order to use currency or unit formatting, the operand of the :number
function would need to include the appropriate currency or unit in addition to its value, and that supporting this would be left to each implementation.
For example, in the JS implementation this could work like this:
const mf = new MessageFormat('en', 'Your total is {$cost :number style=currency}')
const cost = { valueOf: () => 42, options: { currency: 'EUR' } }
mf.format({ cost }) // → 'Your total is €42.00'
With this approach, the placeholder that the translator sees would show that it's a formatted currency, but they would not be able to set the currency; that is provided in the operand.
As we do not specify the formatted results, a conformant implementation could choose to not support currency or unit formatting, and to ignore the relevant options.
We may also want to consider enforcing Edit: I was wrong, see discussion below.exact
selection when style
is not decimal
, as plural or ordinal selection on currency or unit values does not really make sense.