Skip to content

Keep the capital letter of a capitalized irregular word - #545

Merged
NullVoxPopuli merged 1 commit into
emberjs:masterfrom
bardrop-oss:fix-irregular-capitalized
Nov 19, 2026
Merged

NullVoxPopuli merged 1 commit into
emberjs:masterfrom
bardrop-oss:fix-irregular-capitalized

Conversation

@bardrop

@bardrop bardrop commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #135

A capitalized irregular word lost its capital letter:

pluralize('Child')      // 'children' (expected 'Children')
singularize('Children') // 'child'    (expected 'Child')
pluralize('Person')     // 'people'   (expected 'People')

The irregular branch only capitalized the replacement for a camelized word whose last word is itself an irregular key (SalesPerson). A single word like Child has no "last word", so it got the lowercase replacement. That check could also pick the wrong key: with a custom irregular('woman', 'womenfolk'), pluralize('SalesWoman') gave 'SalesWoMen'.

Now the replacement is capitalized when the matched part of the word starts with a capital letter. This gives the same results as ActiveSupport ('Child'.pluralize # => "Children", 'PERSON'.pluralize # => "People"), and keeps the existing CamelCase cases (SuperWoman → SuperWomen, superMan → superMen).

I also ran pluralize/singularize on ~266k words (/usr/share/dict/words plus capitalized forms) against ActiveSupport 8.1: the only changes from master are the capitalized irregular words above, and the remaining differences are the ember-only rules (cow/kine, bonus).

Tests: two new tests in tests/unit/inflector-test.ts (12 asserts fail on master); all 57 tests pass. The cases from #136 are included.

@NullVoxPopuli
NullVoxPopuli merged commit aee817a into emberjs:master Nov 19, 2026
12 of 13 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Child"/"Children" words are lowercased on singularize/pluralize.

2 participants