Skip to content

experimental/currency: Drive monetary grouping entirely by currencyFormats data, making CurrencyEssentialsV1 a numbering-system-attributed marker#8052

Draft
younies wants to merge 1 commit into
unicode-org:mainfrom
younies:currency-custom-grouping
Draft

Conversation

@younies

@younies younies commented Jun 9, 2026

Copy link
Copy Markdown
Member

Changelog

Current CurrencyFormatter shared the un-attributed DecimalSymbolsV1 data payload with standard decimal formatting. This forced monetary values to use standard decimal grouping sizes rather than the explicit monetary grouping pattern defined in currencyFormats ("¤#,##0.00").

This PR completely decouples currency formatters from standard decimal format dependencies and transforms CurrencyEssentialsV1 into a pristine numbering-system-attributed marker:

1. Decimal Formatter Modularity (icu_decimal)

  • Added DecimalFormatter::try_new_from_payloads constructor allowing external components to instantiate internal decimal formatters directly from pre-resolved data payloads.
  • Updated DecimalSubPattern::try_from_items to correctly accept affix symbol items (Currency, Percent, PlusSign, MinusSign) inside prefixes and suffixes.

2. Attributed Provider Data (CurrencyEssentialsV1)

  • Added attributes_domain = "numbering_system" to CurrencyEssentialsV1 data marker.
  • Embedded pub decimal_symbols: DecimalSymbols<'data> directly inside CurrencyEssentials.
  • True Numsys Extractions: Updated datagen (extract_currency_essentials) to dynamically grab symbols and patterns for the exact requested numbering system attribute (e.g., arab for ar-EG) rather than hardcoding latn.
  • Extracted monetary primary_grouping and secondary_grouping sizes directly from currencyFormats.standard.

3. Formatter Wiring (CurrencyFormatter)

  • Completely stripped out DataProvider<icu_decimal::provider::DecimalSymbolsV1> from the trait bounds of try_new_unstable!
  • Projected the monetary symbols payload out of essential data via map_project.
  • Implemented standard two-step attribute fallback loading: tries user requested numsys attribute first (prefs.numbering_system), gracefully falling back to the un-attributed default entry if omitted.
  • Updated compiled data constructor (try_new) to load digits directly from icu_decimal::provider::Baked.

…rmats data, making CurrencyEssentialsV1 a numbering-system-attributed marker

- icu_decimal: Add DecimalFormatter::try_new_from_payloads constructor and allow affix symbols in DecimalSubPattern extractions.
- CurrencyEssentialsV1: Add attributes_domain = "numbering_system" and embed DecimalSymbols struct.
- Datagen: Extract monetary grouping sizes and localized separator symbols for requested numbering systems.
- CurrencyFormatter: Remove DecimalSymbolsV1 trait bound and implement two-step attribute fallback loading.
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.

1 participant