-
Notifications
You must be signed in to change notification settings - Fork 648
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 on Android with style: 'currency' and signDisplay: 'always' truncates currency sign for positive values #789
Labels
bug
Something isn't working
Comments
Similarly, for android this configuration is also not consistent:
Produces the following output on Android:
For iOS and Web it produces the correct output:
|
Having the same issue |
November 30, 2023 and I am running into the same problem. |
I had raised a PR to fix this: #1483 |
facebook-github-bot
pushed a commit
that referenced
this issue
Sep 17, 2024
Summary: Fixes following issue: - #1466 - #1138 - #789 **Why this change is made?** There are few cases where signDisplay is not being handled correctly. Examples: ``` 1. new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR', signDisplay: 'exceptZero', }).format(8537.71) Output: +8,537,71+ Expected: +8.537,71 € 2. new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY', signDisplay: 'exceptZero' }).format(123456.789) Output: +123,457 Expected: +¥123,457 ``` **ChangeLog** This PR updates the implementation and testing of the signDisplay functionality in the DecimalFormat class within the Hermes engine, specifically for Android API level 31 and above. **Key Changes:** Implementation: - Integrated the **setSignAlwaysShown** method of DecimalFormat for API level 31 and above to control the display of the sign (+ or -) based on the signDisplay option. [For more detail about setSignAlwaysShown check [here](https://developer.android.com/reference/android/icu/text/DecimalFormat#setSignAlwaysShown(boolean))] - For API levels below 31, maintained the existing logic for handling sign display, ensuring backward compatibility. Pull Request resolved: #1483 Test Plan: - Added a comprehensive set of test cases in **HermesIntlAndroidTest.java** to validate the behaviour of the signDisplay functionality, specifically for API level 31 and above. - Test cases cover scenarios for signDisplay: `NEVER | ALWAYS | EXCEPTZERO` Reviewed By: avp Differential Revision: D62153166 Pulled By: neildhar fbshipit-source-id: d45c55ae7ffbfbc38ec4b331339859b8c96486c7
facebook-github-bot
pushed a commit
that referenced
this issue
Sep 17, 2024
…1483) Summary: Original Author: [email protected] Original Git: a75e14a Original Reviewed By: avp Original Revision: D62153166 Fixes following issue: - #1466 - #1138 - #789 **Why this change is made?** There are few cases where signDisplay is not being handled correctly. Examples: ``` 1. new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR', signDisplay: 'exceptZero', }).format(8537.71) Output: +8,537,71+ Expected: +8.537,71 € 2. new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY', signDisplay: 'exceptZero' }).format(123456.789) Output: +123,457 Expected: +¥123,457 ``` **ChangeLog** This PR updates the implementation and testing of the signDisplay functionality in the DecimalFormat class within the Hermes engine, specifically for Android API level 31 and above. **Key Changes:** Implementation: - Integrated the **setSignAlwaysShown** method of DecimalFormat for API level 31 and above to control the display of the sign (+ or -) based on the signDisplay option. [For more detail about setSignAlwaysShown check [here](https://developer.android.com/reference/android/icu/text/DecimalFormat#setSignAlwaysShown(boolean))] - For API levels below 31, maintained the existing logic for handling sign display, ensuring backward compatibility. Pull Request resolved: #1483 Pulled By: neildhar Reviewed By: neildhar Differential Revision: D62883944 fbshipit-source-id: df41029b45400b9db038f32727293d5ccda27211
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Description
When you use
Intl.NumberFormat
number withstyle: 'currency'
andsignDisplay: 'always'
it works well enough for negative numbers, but as soon as you try it with a positive number it just removes the currency sign. See the code below.This problem only occures on Android
This is not relevant as Intl doesn't work with JSC:
gradle clean
and confirmed this bug does not occur with JSCHermes version: [email protected]
React Native version: 0.69.3
Platform: arm64-v8a
Steps To Reproduce
Produces the following output on Android:
For iOS and Web it produces the correct output:
The Expected Behavior
Intl.NumberFormat
should produce the same output on each platform.The text was updated successfully, but these errors were encountered: