ecma402 icon indicating copy to clipboard operation
ecma402 copied to clipboard

Add support for more currency symbol variants (e.g. formal)

Open sffc opened this issue 3 years ago • 7 comments

Currently we support four currencyDisplay values:

  • "symbol" to use a localized currency symbol such as €, this is the default value,
  • "narrowSymbol" to use a narrow format symbol ("$100" rather than "US$100"),
  • "code" to use the ISO currency code,
  • "name" to use a localized currency name such as "dollar",

However, CLDR specifies several additional styles. We should consider adding these to ECMA-402.

Feature request for the "formal" style: https://github.com/tc39/ecma402/issues/642

sffc avatar Jan 12 '22 07:01 sffc

In unicode-org/message-format-wg#915, we added required support for currencyDisplay=formalSymbol and currencyDisplay=never in MF2, but left out the "variant" option that ICU also supports.

It would be useful to add these two options to Intl.NumberFormat.

In researching this, I also found at least this user need for the latter option: https://stackoverflow.com/q/68549027

eemeli avatar Nov 17 '24 18:11 eemeli

@sffc When we discussed this on yesterday's call, you raised a concern about "formal" potentially referring to formal symbols of Eastern Asian currencies. Looking into this, CLDR does not provide an alt="formal" for the <symbol> values, but refers to its non-alternate value as the "formal" one. Furthermore, of the Eastern Asian currencies, the only example of something like this that I could find is CNY in Japanese:

let jaSymbol = new Intl.NumberFormat('ja', { style: 'currency', currency: 'CNY', currencyDisplay: 'symbol' });
let jaNarrow = new Intl.NumberFormat('ja', { style: 'currency', currency: 'CNY', currencyDisplay: 'narrowSymbol' });

jaSymbol.format(1);  // "元 1.00"
jaNarrow.format(1);  // "¥1.00"

Is this what you meant, or something else?

eemeli avatar Nov 22 '24 07:11 eemeli

A proposal for this is now available: https://github.com/eemeli/proposal-intl-currency-display-choices

eemeli avatar Nov 22 '24 10:11 eemeli

I was thinking of the formal alt variant, such as this one in zh-Hant:

https://github.com/unicode-org/cldr/blob/b8956436c8cbe80e80630013f6e6c09d7b2e9e28/common/main/zh_Hant.xml#L13662

sffc avatar Nov 22 '24 20:11 sffc

It looks like that case is the only use of alt="formal" in CLDR data, added in CLDR-11190, and there too it's used to differentiate between the $ and NT$ variants, i.e. the "narrow" and "formal" ones that are available for many currencies and locales.

eemeli avatar Nov 25 '24 11:11 eemeli

TG2 discussion: https://github.com/tc39/ecma402/blob/main/meetings/notes-2024-11-25.md#add-support-for-more-currency-symbol-variants-eg-formal-643

sffc avatar Nov 25 '24 18:11 sffc

Proposal: https://github.com/tc39/proposal-intl-currency-display-choices

sffc avatar Dec 16 '24 22:12 sffc