Skip to content

Leave an uppercase uncountable last word alone - #547

Merged
NullVoxPopuli merged 1 commit into
emberjs:masterfrom
bardrop-oss:fix-uppercase-uncountable-last-word
Nov 26, 2026
Merged

NullVoxPopuli merged 1 commit into
emberjs:masterfrom
bardrop-oss:fix-uppercase-uncountable-last-word

Conversation

@bardrop

@bardrop bardrop commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What is wrong

An uncountable word is left alone when it is the whole string, or the last word in lowercase or CamelCase. But when the last word is in ALL CAPS after a space, -, _ or /, it gets inflected:

pluralize('SHEEP');            // 'SHEEP'        (ok)
pluralize('my sheep');         // 'my sheep'     (ok)
pluralize('mySheep');          // 'mySheep'      (ok)

pluralize('my SHEEP');         // 'my SHEEPs'    (expected 'my SHEEP')
pluralize('USER_INFORMATION'); // 'USER_INFORMATIONs'
singularize('new SERIES');     // 'new Series'   (expected 'new SERIES')
singularize('blue_JEANS');     // 'blue_JEAN'

The cause: LAST_WORD_DASHED_REGEX only finds a lowercase last word, and LAST_WORD_CAMELIZED_REGEX only finds one capital letter plus lowercase. An all-caps last word is found by neither, so the uncountable check never sees it.

The fix

Let LAST_WORD_DASHED_REGEX also match an all-uppercase last word. The last word is only used for the uncountable check, and that check already lowercases the word. Nothing else changes.

The test

Added an uppercase uncountable last word is left alone in tests/unit/inflector-test.ts. It covers space, -, / and _, for both pluralize and singularize, and checks that a normal all-caps word (my CAR) still gets inflected.

  • Before the fix: 57 pass, 1 fail (the new test).
  • After the fix: 58 pass.

I also ran the default rules over about 790k words (the system word list plus capitalized, uppercase and multi-word forms). The only outputs that changed were the 420 strings that end in an all-caps uncountable word.

@NullVoxPopuli
NullVoxPopuli merged commit 5f56ad1 into emberjs:master Nov 26, 2026
14 checks passed
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.

2 participants