Skip to content

feat: Add currency display options to CurrencyFormatter (#7785)#7789

Open
younies wants to merge 1 commit intounicode-org:mainfrom
younies:currecy-display-options
Open

feat: Add currency display options to CurrencyFormatter (#7785)#7789
younies wants to merge 1 commit intounicode-org:mainfrom
younies:currecy-display-options

Conversation

@younies
Copy link
Member

@younies younies commented Mar 18, 2026

Enhance the CurrencyFormatterOptions struct to include a currency_display field, allowing for different display styles (Symbol, NarrowSymbol, Code, Name).

Implement tests for each display style in the format module and adding todo to implement these test cases.

Changelog

icu_experimental/currency: Add options for selecting currency format style

  • New enum: CurrencyDisplay
  • New field CurrencyFormatterOptions::currency_display
  • New impl: impl From<CurrencyDisplay> for CurrencyFormatterOptions

Enhance the CurrencyFormatterOptions struct to include a currency_display field, allowing for different display styles (Symbol, NarrowSymbol, Code, Name). Implement tests for each display style in the format module, ensuring correct formatting for USD in the en-US locale.

## Changelog
- Added currency display options to CurrencyFormatter
- Implemented tests for various currency display styles
@younies younies changed the title Add currency display options to CurrencyFormatter (#7785) feat: Add currency display options to CurrencyFormatter (#7785) Mar 18, 2026
@younies younies requested a review from sffc March 18, 2026 15:27
@younies
Copy link
Member Author

younies commented Mar 18, 2026

@sffc

question: As mentioned in #7785, ECMA-402 uses display options for currency formatting. However, this seems to overlap or potentially conflict with the width option.

For example, if a user sets width: Full/Long and display_option: symbol, what should the expected result be?

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove the width option, since it is covered by the currency_display option.


/// The display style for currencies.
/// Default is [`CurrencyDisplay::Symbol`].
pub currency_display: CurrencyDisplay,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the other PR, options should be optional:

Suggested change
pub currency_display: CurrencyDisplay,
pub currency_display: Option<CurrencyDisplay>,

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants