Skip to content

Epic: Measurement Units & Currency in ICU4X #6804

@younies

Description

@younies

Summary

This epic tracks the comprehensive effort to introduce advanced, locale-aware number formatting capabilities into ICU4X. The goal is to provide robust APIs for formatting measurement units, currency, and compact numbers. This includes locale-specific rules, pluralization, various display styles (long, short, narrow, symbol), and compact forms (e.g., "1.5M", "$5K"), all driven by Unicode CLDR data. 🪙📏🔢

Motivation

Correctly formatting numerical data is critical for professional-grade applications. This epic addresses three key areas:

  1. Measurement Units: Essential for scientific, technical, and everyday applications to display quantities like "10 kilograms" or "5 feet" correctly.
  2. Currency: A fundamental requirement for any financial or e-commerce application, ensuring amounts like "$1,250.99" or "10,50 €" are displayed according to local conventions.
  3. Compact Numbers: Vital for modern UIs with limited space, such as dashboards, charts, or social media counters, where numbers need to be presented concisely (e.g., "1.2M followers" instead of "1,200,000 followers").

Scope of Work

This project is broken down into three primary, interconnected workstreams.

1. Measurement Unit Formatting

  • Core Formatter: Implement a foundational UnitFormatter.
  • Styles: Support for long ("10 kilograms"), short ("10 kg"), and narrow ("10kg") styles.
  • Pluralization: Correctly handle plural forms based on the provided number via PluralRules.
  • Compound Units: Support for sequences like "5 feet 10 inches" or "kilometers per hour."
  • Unit Conversion: (Desirable) An engine to convert between compatible units (e.g., meters to feet).

2. Currency Formatting

  • Core Formatter: Implement a CurrencyFormatter.
  • Styles: Support for standard styles like symbol ($100.00), iso_code (USD 100.00), and name (100.00 US dollars).
  • Locale Conventions: Correctly handle the placement of the currency symbol/code, grouping separators, and decimal points based on locale data.
  • Data Integration: Use CLDR data for currency symbols, names, and formatting patterns.

3. Compact Number & Currency Formatting

  • Compact Decimal Formatting: Implement logic to format numbers into a compact form (e.g., 1,500 → "1.5K"; 2,500,000 → "2.5M").
  • Compact Currency Formatting: Extend compact formatting to currencies (e.g., $1,500 → "$1.5K").
  • Pluralization: Integrate with PluralRules, as compact patterns can be plural-sensitive in many languages (e.g., "1 million" vs. "2 millions").
  • Data Integration: Ingest and use CLDR's compact decimal and currency patterns.

Sub-issues

Metadata

Metadata

Assignees

Labels

C-numbersComponent: Numbers, units, currenciesS-epicSize: Major project (create smaller child issues)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions