-
Notifications
You must be signed in to change notification settings - Fork 645
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 signDisplay option displays odd behaviour #1466
Comments
I was trying to fix this issue.
So in order to fix this we surely need to revisit the logic written here: hermes/lib/Platform/Intl/java/com/facebook/hermes/intl/PlatformNumberFormatterICU.java Line 152 in 751d19f
Solution:
I tested this in above failing cases. |
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
…1483) Summary: Original Author: 85783070+shubhamguptadream11@users.noreply.github.com 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
Description
The
signDisplay
option forIntl.NumberFormat
is bugged and has an odd behaviour. E.g. the optionexceptZero
outputs "+8,537,71+
" but it should output+8.537,71 €
. Don't know if this only affects Android.Steps to reproduce
React Native Version
0.74.4
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/Brawl345/rn-signDisplay-bug-reproducer
Screenshots and Videos
The text was updated successfully, but these errors were encountered: