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 can't always display the number's sign #1317

Open
believer opened this issue Feb 15, 2024 · 1 comment
Open

Intl.NumberFormat can't always display the number's sign #1317

believer opened this issue Feb 15, 2024 · 1 comment

Comments

@believer
Copy link

believer commented Feb 15, 2024

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
Screenshot 2024-02-19 at 09 32 37 Screenshot 2024-02-19 at 09 35 53
@neildhar
Copy link
Contributor

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 #1211)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants