Skip to content

feat(currency): Introduce try_new_code constructor#8229

Open
younies wants to merge 2 commits into
unicode-org:mainfrom
younies:currency-iso-formatting
Open

feat(currency): Introduce try_new_code constructor#8229
younies wants to merge 2 commits into
unicode-org:mainfrom
younies:currency-iso-formatting

Conversation

@younies

@younies younies commented Jul 14, 2026

Copy link
Copy Markdown
Member

Introduce try_new_code constructor for formatting with 3-letter ISO currency codes (e.g. USD, EUR) without requiring the CurrencySymbolsV1 data payload.

Note: Stacked on top of #8228 (split-essential).

CI Fix Note: Updated tools/make/tidy.toml to pass --locked when running cargo install --version 1.5.1 cargo-rdme. Without --locked, Cargo resolves the newest compatible dependencies from crates.io and pulls in kstring v2.0.3 (which requires rustc 1.96.0), causing the CI tidy job on rustc 1.95.0 to fail. Passing --locked uses cargo-rdme v1.5.1's pinned lockfile (kstring v2.0.2), restoring clean builds under rustc 1.95.0.

  • Add CurrencyFormatterData::Code variant holding only CurrencyEssentialsV1 and CurrencyCode.
  • Implement try_new_code constructor (with macro-generated buffer constructors and try_new_code_unstable) requiring only DataProvider<CurrencyEssentialsV1>.
  • Update format_fixed_decimal to format Code variants using the ISO code and standard_alpha_next_to_number_pattern.
  • Add test_code in format.rs verifying ISO code formatting behavior.
  • Add --locked to cargo-rdme installation in tools/make/tidy.toml.

Changelog

  • Introduce try_new_code constructor for formatting with 3-letter ISO currency codes without requiring CurrencySymbolsV1.
  • Fix CI tidy job by passing --locked when installing cargo-rdme.

TAG=agy
CONV=d044eeab-1ec7-4391-9cf0-a6d3d9e6edf0

Separate symbol mappings (placeholders, pattern configurations, and default pattern selection) into a dedicated CurrencySymbolsV1 marker and struct (symbols.rs), leaving CurrencyEssentialsV1 purely for core layout rules (patterns and indices).

- Create CurrencySymbolsV1 with pattern_config_map, placeholders, and default_pattern_config in components/experimental/src/dimension/provider/currency/symbols.rs.
- Extract CurrencySymbolsV1 in provider/source/src/currency/symbols.rs from CLDR (symbol and symbol-narrow).
- Update CurrencyEssentialsV1 in essentials.rs to only retain patterns and indices.
- Update CurrencyFormatterData::Essential and formatters in formatter.rs & compact_formatter.rs to require and use both CurrencyEssentialsV1 and CurrencySymbolsV1.
- Update provider registry (provider/registry/src/lib.rs) and regenerate test and baked data for CurrencySymbolsV1 and CurrencyEssentialsV1.

TAG=agy
CONV=d044eeab-1ec7-4391-9cf0-a6d3d9e6edf0
@younies younies force-pushed the currency-iso-formatting branch from 2c83b9a to 9416f65 Compare July 14, 2026 14:21
@younies younies changed the title feat(currency): Introduce try_new_code and try_new_iso_code constructors feat(currency): Introduce try_new_code constructor Jul 14, 2026
Introduce try_new_code constructor for formatting with 3-letter ISO currency codes (e.g. USD, EUR) without requiring the CurrencySymbolsV1 data payload.

- Add CurrencyFormatterData::Code variant holding only CurrencyEssentialsV1 and CurrencyCode.
- Implement try_new_code constructor (with macro-generated buffer constructors and try_new_code_unstable) requiring only DataProvider<CurrencyEssentialsV1>.
- Update format_fixed_decimal to format Code variants using the ISO code and standard_alpha_next_to_number_pattern.
- Add test_code in format.rs verifying ISO code formatting behavior.
- Add --locked to cargo-rdme installation in tools/make/tidy.toml to fix CI tidy builds.

TAG=agy
CONV=d044eeab-1ec7-4391-9cf0-a6d3d9e6edf0
@younies younies force-pushed the currency-iso-formatting branch from 9416f65 to 2498c10 Compare July 14, 2026 14:57
@younies younies marked this pull request as ready for review July 16, 2026 13:28
@younies younies requested review from a team, Manishearth, robertbastian and sffc as code owners July 16, 2026 13:28
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