Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intl.NumberFormat currencyDisplay 'name' does not respect currency #914

Closed
asherLZR opened this issue Feb 16, 2023 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@asherLZR
Copy link

Bug Description

Intl.NumberFormat does not respect the currency input when currencyDisplay is "name". Without currencyDisplay, currency is correctly taken into account.

Hermes version:
React Native version (if any): 0.70.6 & 0.71.3
OS version (if any): iOS 15.4
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): arm64-v8a

Steps To Reproduce

Run the below code sample on iOS.

The Expected Behavior

new Intl.NumberFormat('de-DE', {
  style: 'currency',
  currency: 'USD',
  currencyDisplay: 'name',
}).format(2)

// expected: "2,00 US-Dollar"
// actual: "2,00 Euro" - wrong

new Intl.NumberFormat('de-DE', {
  style: 'currency',
  currency: 'USD'
}).format(2)

// expected: "2,00 $"
// actual: "2,00 $" - correct
@asherLZR asherLZR added the bug Something isn't working label Feb 16, 2023
@asherLZR
Copy link
Author

Potentially the numberFormatter needs to have the currency defined in the locale identifier when it's of type .currencyPlural.

let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .currencyPlural
numberFormatter.locale = Locale(identifier: "de-DE@currency=USD")

cipolleschi pushed a commit that referenced this issue Mar 7, 2023
…lural (#919)

Summary:
Intl.NumberFormat does not respect the currency input when currencyDisplay is "name". Without currencyDisplay, currency is correctly taken into account.

Resolves #914

Pull Request resolved: #919

Test Plan:
Build Hermes and installed on RN application, tested against multiple currency/locale pairs.

```
new Intl.NumberFormat('de-DE', {
  style: 'currency',
  currency,
  currencyDisplay: 'name',
}).format(2)
```

Reviewed By: mhorowitz

Differential Revision: D43437187

Pulled By: neildhar

fbshipit-source-id: 47a7b322fbb498e431b7db9130da3a852c5de873
facebook-github-bot pushed a commit that referenced this issue Apr 7, 2023
…lural (#919) (#919)

Summary:
Original Author: asher.lim@klarna.com
Original Git: 059d085

Intl.NumberFormat does not respect the currency input when currencyDisplay is "name". Without currencyDisplay, currency is correctly taken into account.

Resolves #914

Pull Request resolved: #919

Original Reviewed By: mhorowitz

Original Revision: D43437187

Reviewed By: tmikov

Differential Revision: D44771026

fbshipit-source-id: 21f00a00ba073a9ad9b58598a828b547434d9e0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant