hermes icon indicating copy to clipboard operation
hermes copied to clipboard

Android: PlatformNumberFormatterICU does not support currencyDisplay=narrowSymbol

Open mcuelenaere opened this issue 4 years ago • 3 comments

Bug Description

  • [ ] I have run gradle clean and confirmed this bug does not occur with JSC

Hermes version: 0.8.1 React Native version (if any): 0.65.1 OS version (if any): Android 10 Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): n/a

Steps To Reproduce

  1. Executeconsole.log(new Intl.NumberFormat('en', { currencyDisplay: 'narrowSymbol', style: 'currency', currency: 'USD' }).format(100));
  2. Observe 100 US$ being displayed

The Expected Behavior

$100

Fix

I've traced this down to https://github.com/facebook/hermes/blob/main/lib/Platform/Intl/java/com/facebook/hermes/intl/PlatformNumberFormatterICU.java#L73-L74 calling https://github.com/facebook/hermes/blob/main/lib/Platform/Intl/java/com/facebook/hermes/intl/IPlatformNumberFormatter.java#L213-L219, which does not use https://developer.android.com/reference/android/icu/util/Currency#NARROW_SYMBOL_NAME (which is only available on API>=30).

I could make a rudimentary PR for this, but since we'll be going with a different approach in our project (we need to support Android devices older than 11), I won't be able to validate/test the PR. So instead I created this issue so others have a good starting point if they would want to fix this issue.

mcuelenaere avatar Sep 21 '21 15:09 mcuelenaere

Facing the same issue

regalstreak avatar May 09 '23 12:05 regalstreak

Facing the same issue

The same issue , do you have any solution?

NoahZJY avatar May 27 '24 09:05 NoahZJY

I apologise we haven't previously responded here. Hermes Intl has been implemented on top of platform APIs which means that it isn't always possible to implement the entirety of Intl, and we've run into problems with varying support on different platforms and versions.

We have plans to migrate our implementation to provide a more feature rich implementation (see the discussion in https://github.com/facebook/hermes/discussions/1211).

neildhar avatar Jun 10 '24 23:06 neildhar