facebook / facebook/hermes

Android: PlatformNumberFormatterICU does not support currencyDisplay=narrowSymbol

Open
#600 3 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

## 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. Execute`console.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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.