globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

offer a singularize module or function #880

Closed SamMaxwell closed 4 years ago

SamMaxwell commented 4 years ago

It's great to have a pluralization capability, but what about singularization?

Sometimes code must pluralize nouns that may already be in plural form. It is more resilient to first singularize it before pluralization. My use-case is that my code pulls nouns from database schema schema objects (table names) that may use plural names, or singular, or a combination of both. My code cannot be opinionated about how the user names their tables.

I guess another approach would be to have an isPlural function to detect whether the noun is already plural.

But then there is also the case where the existing plural form may not be the best or most common, and the process of singularization before pluralization could "clean it up" (e.g. "Gymnasia" -> "Gymnasium" -> "Gymnasiums").

rxaviers commented 4 years ago

I believe this issue was opened by mistake. Globalize's plural functionality is about plural count form, not about any transformation.

SamMaxwell commented 4 years ago

You are correct. I didn't understand the functionality.