Skip to content

feat(@formatjs/intl-pluralrules): support notation/compactDisplay (c/e operands)#5914

Closed
longlho wants to merge 1 commit intographite-base/5914from
01-14-feat_formatjs_intl-pluralrules_support_notation_compactdisplay_c_e_operands_
Closed

feat(@formatjs/intl-pluralrules): support notation/compactDisplay (c/e operands)#5914
longlho wants to merge 1 commit intographite-base/5914from
01-14-feat_formatjs_intl-pluralrules_support_notation_compactdisplay_c_e_operands_

Conversation

@longlho
Copy link
Copy Markdown
Member

@longlho longlho commented Jan 15, 2026

TL;DR

Add support for compact notation in Intl.PluralRules with the c/e operand for languages that use exponent-based plural rules.

What changed?

  • Added notation and compactDisplay options to Intl.PluralRules to support compact notation
  • Updated the GetOperands function to include the CompactExponent operand
  • Modified the plural rules compiler to pass the exponent parameter to plural functions
  • Added support for calculating compact exponents using NumberFormat locale data
  • Updated type definitions and interfaces to support the new parameters
  • Added tests for compact notation with various locales

How to test?

  1. Create a PluralRules instance with compact notation:
const pr = new Intl.PluralRules('fr', {notation: 'compact'});
pr.select(1000000); // Should return 'many' for French
  1. Test with different locales that use compact notation rules:
const locales = ['ca', 'es', 'fr', 'it', 'pt', 'pt-PT'];
for (const locale of locales) {
  const pr = new Intl.PluralRules(locale, {notation: 'compact'});
  console.log(locale, pr.select(1000000));
}
  1. Compare compact vs standard notation:
const prCompact = new Intl.PluralRules('fr', {notation: 'compact'});
const prStandard = new Intl.PluralRules('fr');
console.log(prCompact.select(1200000), prStandard.select(1200000));

Why make this change?

Several languages (including French, Spanish, Italian, Portuguese, and Catalan) have plural rules that depend on the compact notation exponent. For example, in French, numbers formatted in millions use a different plural form than the same numbers in standard notation.

This change enables correct plural selection for compact-formatted numbers in these languages, which is essential for proper localization of applications that use compact number formatting alongside pluralization.

Copy link
Copy Markdown
Member Author

longlho commented Jan 15, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • main - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@longlho longlho force-pushed the 01-14-feat_formatjs_intl-pluralrules_support_notation_compactdisplay_c_e_operands_ branch from f867d7d to a7ff231 Compare January 15, 2026 04:43
@longlho longlho force-pushed the 01-14-feat_formatjs_intl-pluralrules_support_notation_compactdisplay_c_e_operands_ branch from a7ff231 to 930922b Compare January 15, 2026 04:48
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Jan 15, 2026

Merge activity

  • Jan 15, 5:36 AM UTC: longlho added this pull request to the Graphite merge queue.
  • Jan 15, 5:36 AM UTC: CI is running for this pull request on a draft pull request (#5916) due to your merge queue CI optimization settings.
  • Jan 15, 5:46 AM UTC: Merged by the Graphite merge queue via draft PR: #5916.

graphite-app Bot pushed a commit that referenced this pull request Jan 15, 2026
…e operands) (#5914)

### TL;DR

Add support for compact notation in `Intl.PluralRules` with the `c/e` operand for languages that use exponent-based plural rules.

### What changed?

- Added `notation` and `compactDisplay` options to `Intl.PluralRules` to support compact notation
- Updated the `GetOperands` function to include the `CompactExponent` operand
- Modified the plural rules compiler to pass the exponent parameter to plural functions
- Added support for calculating compact exponents using NumberFormat locale data
- Updated type definitions and interfaces to support the new parameters
- Added tests for compact notation with various locales

### How to test?

1. Create a PluralRules instance with compact notation:
```js
const pr = new Intl.PluralRules('fr', {notation: 'compact'});
pr.select(1000000); // Should return 'many' for French
```

2. Test with different locales that use compact notation rules:
```js
const locales = ['ca', 'es', 'fr', 'it', 'pt', 'pt-PT'];
for (const locale of locales) {
  const pr = new Intl.PluralRules(locale, {notation: 'compact'});
  console.log(locale, pr.select(1000000));
}
```

3. Compare compact vs standard notation:
```js
const prCompact = new Intl.PluralRules('fr', {notation: 'compact'});
const prStandard = new Intl.PluralRules('fr');
console.log(prCompact.select(1200000), prStandard.select(1200000));
```

### Why make this change?

Several languages (including French, Spanish, Italian, Portuguese, and Catalan) have plural rules that depend on the compact notation exponent. For example, in French, numbers formatted in millions use a different plural form than the same numbers in standard notation.

This change enables correct plural selection for compact-formatted numbers in these languages, which is essential for proper localization of applications that use compact number formatting alongside pluralization.
@graphite-app graphite-app Bot changed the base branch from 01-14-feat_formatjs_intl-pluralrules_support_selectrange to graphite-base/5914 January 15, 2026 05:46
@graphite-app graphite-app Bot closed this Jan 15, 2026
@graphite-app graphite-app Bot deleted the 01-14-feat_formatjs_intl-pluralrules_support_notation_compactdisplay_c_e_operands_ branch January 15, 2026 05:46
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