Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

feat(@formatjs/intl-unified-numberformat): add currencyDisplay… #332

Merged
merged 1 commit into from
Dec 2, 2019

Conversation

pyrocat101
Copy link
Member

This PR adds the support for new narrowSymbol value of the currencyDisplay option to UnifiedNumberFormat.

Implementation-wise, it depends on 2 assumptions:

  1. If there are no narrow symbol for a particular currency, falling back to symbol is equivalent to falling back to ISO currency code as instructed in the spec.
  2. There is one and only one currency token in the returning array of formatToParts.

Both of these assumptions are verified with a script scripts/assert_currency_symbols.ts against Google Chrome 78.

If a number is to be formatted to narrowSymbol currency, then first this is formatted to parts with currencyDisplay: 'symbol' option, and then the code simply replaces the occurrence of currency type in the parts with the narrow symbol counterpart if it is available for the specified locale + currency combination.

@longlho longlho changed the title feat(intl-unified-numberformat): add support for currencyDisplay: narrowSymbol feat(@formatjs/intl-unified-numberformat): add currencyDisplay… Dec 2, 2019
@longlho longlho merged commit 0cf8629 into master Dec 2, 2019
@longlho longlho deleted the numberFormat-currencyDisplay branch December 2, 2019 02:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants