Skip to content

fix: pluralize nucleus/nuclei correctly#121

Merged
p-kuen merged 1 commit into
dreamerslab:masterfrom
rlorenzo:fix-nucleus-pluralization
May 13, 2026
Merged

fix: pluralize nucleus/nuclei correctly#121
p-kuen merged 1 commit into
dreamerslab:masterfrom
rlorenzo:fix-nucleus-pluralization

Conversation

@rlorenzo
Copy link
Copy Markdown
Contributor

@rlorenzo rlorenzo commented May 13, 2026

This PR addresses issue #71.

Right now, pluralize('nucleus') doesn't actually pluralize, and a few related forms come back mangled:

pluralize('nucleus')     // 'nucleus'   (expected 'nuclei')
pluralize('nuclei')      // 'nucleis'   (expected 'nuclei')
singularize('nuclei')    // 'nuclei'    (expected 'nucleus')
singularize('nucleuses') // 'nucleuse'  (expected 'nucleus')
singularize('nucleus')   // 'nucleu'    (expected 'nucleus')

After this PR, each of those returns what you'd expect. pluralize('nucleuses') still gives back 'nucleuses' since it's already plural.

How

I followed the same shape as the existing criterion/criteria and genus/genera rules: three anchored regexes (^(nucle)us$, ^(nucle)i$, ^(nucle)uses$) added to regex.singular and regex.plural, with matching skip + replace entries in pluralRules and singularRules. Because the patterns are anchored to the nucle stem, they can't accidentally catch other -us or -i words.

Test plan

  • npm test passes (15 existing tests, plus 6 new assertions covering every case the issue mentioned)

Adds anchored regex rules so:
- pluralize('nucleus')   === 'nuclei'
- pluralize('nuclei')    === 'nuclei'
- pluralize('nucleuses') === 'nucleuses'
- singularize('nuclei')    === 'nucleus'
- singularize('nucleuses') === 'nucleus'
- singularize('nucleus')   === 'nucleus'

Patterns are anchored to the `nucle` stem so they cannot
match other -us/-i words.

Fixes dreamerslab#71
@rlorenzo rlorenzo force-pushed the fix-nucleus-pluralization branch from 05dd49e to f1ed06f Compare May 13, 2026 05:58
@rlorenzo
Copy link
Copy Markdown
Contributor Author

@p-kuen The merge conflict was resolved.

@p-kuen p-kuen merged commit cfeb97c into dreamerslab:master May 13, 2026
1 check passed
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.

2 participants