Skip to content

Pluralization and capitalization issues #20

@dvli2007

Description

@dvli2007

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!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requests: fixedwas fixed or solution offered

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions