Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluralization and capitalization issues #20

Closed
dvli2007 opened this issue Apr 13, 2019 · 4 comments · Fixed by #59
Closed

Pluralization and capitalization issues #20

dvli2007 opened this issue Apr 13, 2019 · 4 comments · Fixed by #59
Assignees
Labels
enhancement New feature or request s: fixed was fixed or solution offered

Comments

@dvli2007
Copy link

dvli2007 commented Apr 13, 2019

Pluralize() should in theory pluralize a name while maintaining the cases. For example, FooBar -> FooBars.

However, there are a few cases where the pluralization produces unintentional lowercasing.

  1. Half -> halves
    It seems that when the whole word matches an item in the singularToPlural map, the entire word gets converted in lowercase. On the contrary, this seems to behave correctly when a singular word is attached to another one, such as the case of LemonHalf -> LemonHalves.

  2. SmartPerson -> Smartpeople
    It seems that when the suffix matches one of the pluralRules, the entire matched portion remains lowercase.

  3. SuperbOx -> Superboxes
    It seems that camel-casing is not respected for breaking up words. In fact, the pluralRules seem to be applied first (box -> boxes) before the singularToPlural rules (ox -> oxen). In fact, it seems that when ox is attached to another word, it will never be changed to oxen (example: big_ox -> big_oxes).

Overall, having consistent behavior here is important as this package is used by gobuffalo/pop for auto-generating table names from camel-case structs. Happy to help discuss potential solutions!

@markbates
Copy link
Member

markbates commented Apr 13, 2019 via email

@pgier
Copy link
Contributor

pgier commented Nov 21, 2019

PR #29 should fix the big_ox -> big_oxes issue

@rameshgkwd05
Copy link

The above PR #29 covers multi-words.
But what about general words, those should be pluralized according to this Grammarly article: https://www.grammarly.com/blog/plural-nouns/

Maybe a more elegant suffix-function is needed.

@sio4 sio4 self-assigned this Sep 3, 2022
@sio4 sio4 added the enhancement New feature or request label Sep 3, 2022
sio4 added a commit that referenced this issue Sep 3, 2022
@sio4 sio4 closed this as completed in a419537 Sep 3, 2022
@sio4
Copy link
Member

sio4 commented Sep 3, 2022

Thank you for reporting the issue. it was fixed by #59

@sio4 sio4 added the s: fixed was fixed or solution offered label Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request s: fixed was fixed or solution offered
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants