Skip to content

Honour currencyDisplay: 'narrowSymbol' in Intl.NumberFormat on Android - #2333

Open
scraby91 wants to merge 1 commit into
meta:static_hfrom
scraby91:fix-android-narrow-symbol
Open

scraby91 wants to merge 1 commit into
meta:static_hfrom
scraby91:fix-android-narrow-symbol

Conversation

@scraby91

@scraby91 scraby91 commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

Fixes #2332.

On Android, currencyDisplay: 'narrowSymbol' formats exactly like 'symbol': CurrencyDisplay.getNameStyle() maps NARROWSYMBOL to Currency.SYMBOL_NAME. For example, ro-RO RON gives "7,99 RON" instead of "7,99 lei", and en-CA USD gives "US$7.99" instead of "$7.99".

This maps NARROWSYMBOL to Currency.NARROW_SYMBOL_NAME on API 30+, where android.icu.util.Currency exposes it. Below API 30 the standard symbol stays, as today. getNameStyle() is only read by PlatformNumberFormatterICU.setCurrency, and symbol, code and name are unchanged.

Test Plan

  • Added HermesIntlAndroidTest.testCurrencyDisplayNarrowSymbolForApiLevelAbove30: en-CA USD formats as US$7.99 with symbol and $7.99 with narrowSymbol.
  • I have not built Hermes or run the instrumentation tests locally, and I have not run utils/format.sh.
  • IPlatformNumberFormatter.java compiles against android-36 (javac 17). The bytecode for getNameStyle() returns 3 (NARROW_SYMBOL_NAME) for NARROWSYMBOL when SDK_INT >= 30, otherwise 0.
  • I ran the ICU calls PlatformNumberFormatterICU.setCurrency makes, standalone (app_process) on an Android 16 (API 36) x86_64 emulator, once with each name style. NBSP is shown as a space:
Locale Currency SYMBOL_NAME NARROW_SYMBOL_NAME
ro-RO RON 7,99 RON 7,99 lei
en-CA USD US$7.99 $7.99
pl-PL PLN 7,99 zł 7,99 zł
de-DE EUR 7,99 € 7,99 €
en-GB GBP £7.99 £7.99
de-CH CHF CHF 7.99 CHF 7.99
en-US USD $7.99 $7.99

CurrencyDisplay.getNameStyle() mapped NARROWSYMBOL to
Currency.SYMBOL_NAME, so 'narrowSymbol' formatted exactly like 'symbol'
(en-CA USD gave "US$7.99" instead of "$7.99", ro-RO RON gave "7,99 RON"
instead of "7,99 lei"). Map it to Currency.NARROW_SYMBOL_NAME on API 30+,
where android.icu exposes it. Older devices keep the standard symbol.

Fixes meta#2332

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CqvJEe4JtmFFMTnNXzyA3
@meta-cla

meta-cla Bot commented Nov 20, 2026

Copy link
Copy Markdown

Hi @scraby91!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Nov 20, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intl.NumberFormat ignores currencyDisplay: 'narrowSymbol' on Android

1 participant