Intl.NumberFormat can't always display the number's sign
Description
Intl.NumberFormat has a signDisplay option that handles when to display the number sign. If we set it to always it should always display the sign, but React Native doesn't display a plus sign.
Steps to reproduce
// Tested with `en-US` as well without any difference.
const locale = 'sv-SE'
const numberFormatter = new Intl.NumberFormat(locale, { signDisplay: 'always' })
const percentFormatter = new Intl.NumberFormat(locale, { style: 'percent', signDisplay: 'always' })
numberFormatter.format(22) // Displays 22, but should display +22
percentFormatter.format(0.22) // Displays 22 %, but should display +22 %
React Native Version
0.73.4
Affected Platforms
Runtime - iOS
Output of npx react-native info
System:
OS: macOS 14.3
CPU: (10) arm64 Apple M2 Pro
Memory: 135.84 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.18.2
path: ~/Library/Caches/fnm_multishells/59707_1707991116304/bin/node
Yarn:
version: 1.22.19
path: ~/code/seb/Spark-blackbird/apps/blackbird/node_modules/.bin/yarn
npm:
version: 9.8.1
path: ~/Library/Caches/fnm_multishells/59707_1707991116304/bin/npm
Watchman:
version: 2024.01.22.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /Users/rickard/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.2
- iOS 17.2
- macOS 14.2
- tvOS 17.2
- visionOS 1.0
- watchOS 10.2
Android SDK:
API Levels:
- "33"
- "34"
Build Tools:
- 30.0.3
- 33.0.0
- 33.0.1
- 34.0.0
System Images:
- android-33 | Google APIs ARM 64 v8a
- android-33 | Google Play ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11255304
Xcode:
version: 15.2/15C500b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /Users/rickard/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 13.5.1
wanted: "*"
react:
installed: 18.2.0
wanted: "*"
react-native:
installed: 0.73.4
wanted: "*"
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
No stacktrace or logs
Reproducer
https://snack.expo.dev/95Z5GGAwW7qZzA0Ne4Huf
Screenshots and Videos
| Web | iOS |
|---|---|
Thank you for reporting this. Our Intl implementation on iOS is implemented on top of APIs exposed by Foundation, which means that some functionality is difficult or impossible to implement. signDisplay is one of those features, and is currently unsupported.
However, we're aware of this, and have a plan in the long term to fix it through an overhaul of our Intl implementation. (see https://github.com/facebook/hermes/discussions/1211)