Skip to content

Fix: Apply absolute value logic in PluralRules - #506

Merged
axunonb merged 1 commit into
mainfrom
pr/legacy-plural-rules
Oct 24, 2025
Merged

Fix: Apply absolute value logic in PluralRules#506
axunonb merged 1 commit into
mainfrom
pr/legacy-plural-rules

Conversation

@axunonb

@axunonb axunonb commented Oct 17, 2025

Copy link
Copy Markdown
Member

THIS COMMIT HAS BEEN REMOVED FROM MAIN

This PR addresses a long-standing inconsistency in the pluralization logic used by PluralRules. Previously, the implementation did not explicitly evaluate the absolute value of the input number, contrary to the CLDR specification. This led to incorrect plural category resolution for negative numbers, which typically defaulted to the OTHER category.

Changes

  • The decimal argument passed to all PluralRules delegates is now transformed to its absolute value before evaluation.
  • This change ensures that plural category resolution aligns with CLDR expectations, particularly because locales with plural forms depend on numeric value regardless of sign.

Impact

  • Fixes incorrect plural category resolution for negative numbers in locales such as DualOneOther, where the number of plural word variants influences the outcome.
  • May affect pluralization behavior in edge cases across multiple locales. Unit tests have been updated to reflect the corrected logic.
  • The change affects PluralLocalizationFormatter and TimeFormatter.
  • Thoroughly test the new version in your localization workflows, especially if you rely on custom pluralization delegates or locale-specific plural form resolution. This change may surface previously masked edge cases.

Versioning

  • The PR will be published with a new minor version, as this change corrects a bug but may alter behavior in downstream formatting logic.

Background

See discussion in #503 and #497 for context.
Resolves #503

This PR addresses a long-standing inconsistency in the pluralization logic used by `PluralRules`.
Previously, the implementation did not explicitly evaluate the absolute value of the input number, contrary to the CLDR specification.
This led to incorrect plural category resolution for negative numbers, which typically defaulted to the `OTHER` category.

#### Changes
- The decimal argument passed to all `PluralRules` delegates is now transformed to its absolute value before evaluation.
- This change ensures that plural category resolution aligns with CLDR expectations, particularly because locales with plural forms depend on numeric value regardless of sign.

#### Impact
- Fixes incorrect plural category resolution for negative numbers in locales such as `DualOneOther`, where the number of plural word variants influences the outcome.
- May affect pluralization behavior in edge cases across multiple locales. Unit tests have been updated to reflect the corrected logic.
- The change affects `PluralLocalizationFormatter` and `TimeFormatter`.
- **Thoroughly test the new version in your localization workflows**, especially if you rely on custom pluralization delegates or locale-specific plural form resolution. This change may surface previously masked edge cases.

#### Versioning
- The PR will be published with a new **minor version**, as this change corrects a bug but may alter behavior in downstream formatting logic.

#### Background
See discussion in #503 and #497 for context.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 17, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97%. Comparing base (040f236) to head (18b0e39).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #506   +/-   ##
===================================
  Coverage    97%    97%           
===================================
  Files        99     99           
  Lines      3424   3491   +67     
===================================
+ Hits       3319   3386   +67     
  Misses      105    105           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@imprima imprima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@imprima
imprima marked this pull request as ready for review October 24, 2025 18:58
@axunonb
axunonb merged commit b22ccfd into main Oct 24, 2025
9 checks passed
axunonb added a commit that referenced this pull request Nov 1, 2025
* Fix: Apply absolute value logic in `PluralRules` (#506)

This PR addresses a long-standing inconsistency in the pluralization logic used by `PluralRules`.
Previously, the implementation did not explicitly evaluate the absolute value of the input number, contrary to the CLDR specification.
This led to incorrect plural category resolution for negative numbers, which typically defaulted to the `OTHER` category.

#### Changes
- The decimal argument passed to all `PluralRules` delegates is now transformed to its absolute value before evaluation.
- This change ensures that plural category resolution aligns with CLDR expectations, particularly because locales with plural forms depend on numeric value regardless of sign.

#### Impact
- Fixes incorrect plural category resolution for negative numbers in locales such as `DualOneOther`, where the number of plural word variants influences the outcome.
- May affect pluralization behavior in edge cases across multiple locales. Unit tests have been updated to reflect the corrected logic.
- The change affects `PluralLocalizationFormatter` and `TimeFormatter`.
- **Thoroughly test the new version in your localization workflows**, especially if you rely on custom pluralization delegates or locale-specific plural form resolution. This change may surface previously masked edge cases.

#### Versioning
- The PR will be published with a new **minor version**, as this change corrects a bug but may alter behavior in downstream formatting logic.

#### Background
See discussion in #503 and #497 for context.

* chore(deps): bump actions/upload-artifact from 4 to 5

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix error in Demo project

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: axunonb <axunonb@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
axunonb added a commit that referenced this pull request Nov 12, 2025
This PR addresses a long-standing inconsistency in the pluralization logic used by `PluralRules`.
Previously, the implementation did not explicitly evaluate the absolute value of the input number, contrary to the CLDR specification.
This led to incorrect plural category resolution for negative numbers, which typically defaulted to the `OTHER` category.

#### Changes
- The decimal argument passed to all `PluralRules` delegates is now transformed to its absolute value before evaluation.
- This change ensures that plural category resolution aligns with CLDR expectations, particularly because locales with plural forms depend on numeric value regardless of sign.

#### Impact
- Fixes incorrect plural category resolution for negative numbers in locales such as `DualOneOther`, where the number of plural word variants influences the outcome.
- May affect pluralization behavior in edge cases across multiple locales. Unit tests have been updated to reflect the corrected logic.
- The change affects `PluralLocalizationFormatter` and `TimeFormatter`.
- **Thoroughly test the new version in your localization workflows**, especially if you rely on custom pluralization delegates or locale-specific plural form resolution. This change may surface previously masked edge cases.

#### Versioning
- The PR will be published with a new **minor version**, as this change corrects a bug but may alter behavior in downstream formatting logic.

#### Background
See discussion in #503 and #497 for context.
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.

Plural localization for negative number does not apply CLDR plural rules

2 participants