Repository navigation
Conversation
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
|
Hi @scraby91! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
Fixes #2332.
On Android,
currencyDisplay: 'narrowSymbol'formats exactly like'symbol':CurrencyDisplay.getNameStyle()mapsNARROWSYMBOLtoCurrency.SYMBOL_NAME. For example,ro-RORON gives"7,99 RON"instead of"7,99 lei", anden-CAUSD gives"US$7.99"instead of"$7.99".This maps
NARROWSYMBOLtoCurrency.NARROW_SYMBOL_NAMEon API 30+, whereandroid.icu.util.Currencyexposes it. Below API 30 the standard symbol stays, as today.getNameStyle()is only read byPlatformNumberFormatterICU.setCurrency, andsymbol,codeandnameare unchanged.Test Plan
HermesIntlAndroidTest.testCurrencyDisplayNarrowSymbolForApiLevelAbove30:en-CAUSD formats asUS$7.99withsymboland$7.99withnarrowSymbol.utils/format.sh.IPlatformNumberFormatter.javacompiles againstandroid-36(javac 17). The bytecode forgetNameStyle()returns 3 (NARROW_SYMBOL_NAME) forNARROWSYMBOLwhenSDK_INT >= 30, otherwise 0.PlatformNumberFormatterICU.setCurrencymakes, standalone (app_process) on an Android 16 (API 36) x86_64 emulator, once with each name style. NBSP is shown as a space:SYMBOL_NAMENARROW_SYMBOL_NAME