ecma402 icon indicating copy to clipboard operation
ecma402 copied to clipboard

Intl.NumberFormat notationSubPatterns can include sign and currency symbol

Open pyrocat101 opened this issue 5 years ago • 0 comments

In Intl.NumberFormat spec, the notationSubPattern is used to "expand" the {number} pattern part in the abstract operation PartitionNumberPattern. The substitution of currency and sign parts are independent from the notation sub-pattern.

The spec also states that the notationSubPattern is only parametrized by locale:

[[LocaleData]].[[<locale>]] must also have a [[notationSubPatterns]] field for all locale values locale. The value of this field must be a Record, which must have two fields: [[scientific]] and [[compact]]. The [[scientific]] field must be a string value containing the substrings "{number}", "{scientificSeparator}", and "{scientificExponent}". The [[compact]] field must be a Record with two fields: "short" and "long". Each of these fields must be a Record with integer keys corresponding to all discrete magnitudes the implementation supports for compact notation. Each of these fields must be a string value which may contain the substring "{number}". Strings descended from "short" must contain the substring "{compactSymbol}", and strings descended from "long" must contain the substring "{compactName}".

But for sw locale, the compact display pattern is dependent on the sign and the style. This is the result from Google Chrome 81:

Intl.NumberFormat('sw', {notation: 'compact', compactDisplay: 'long'}).format(-100000)
//-> "elfu -100"
Intl.NumberFormat('sw', {notation: 'compact', compactDisplay: 'long', style: 'currency', currency: 'usd', currencySign: 'accounting'}).format(-100000)
//-> "US$laki -100"

Here is the related CLDR patterns:

  1. https://github.com/unicode-cldr/cldr-numbers-full/blob/master/main/sw/numbers.json#L33-L58
  2. https://github.com/unicode-cldr/cldr-numbers-full/blob/master/main/sw/numbers.json#L112-L135

pyrocat101 avatar May 16 '20 21:05 pyrocat101