-
Notifications
You must be signed in to change notification settings - Fork 62
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
[Feature Request] Could pluralize
be dynamic based on a count argument?
#58
Comments
I like this idea, but since this code references Rails as an inspiration it might be best to swap your proposed arguments to match Rails' API which would be error_count = 1
pluralize(error_count, "error") I ended up implementing my own local copy of from inflection import pluralize as _pluralize
def pluralize(count, singular):
if count == 1:
return f"1 {singular}"
return f"{count} {_pluralize(singular)}" What do you think about adding something like that in @jpvanhal? |
Yeah that's kind of exactly what I was thinking about. It'd be nice to have this ability IMO :) If there is anything I can help with let me know. If not looks like there's already the begining of a patch here. |
I'm not sure if it should be patched in directly as is because it breaks older implementations by changing the function signature and return value. For example, what if you might want the pluralized word returned without the count? This use case isn't an issue with Ruby because Ruby has a What do you think about maybe introducing a Personally I always want the count in the use cases I've been using it for so I'm ok with either solution. Really comes down to what the maintainer of this library wants to do! |
Good point. And yeah that was the proposal I was making with a probably badly named function that I called |
If you wanted to start a PR with my code snippet and |
@nickjj I really don't mind either! If you don't have time I could look into it this weekend. But also, I think it might be a good idea to see if there is buy in from the maintainer. It's always annoying for them to say no after someone did some work and it's wasted time on the contributor. What do you think? |
Yeah we could wait for a reply here before taking any type of action. |
I was wondering if there would be a case for having a version of
pluralize()
that could automatically decide on whether to pluralise things based on a count similar to what theinflect
package does. Their API looks like this:Looking at the code, I think it'd be an easy change or addition if you would rather keep
pluralize()
to only do plural and we could find a more generic name which could benumber_agreement()
or whaetever we can come up with.I'd be more than happy to contribute to the feature if this change was welcome.
I really like your package better than
inflect
and would rather not add a new dependency into my tools or implement this decision every time from "scratch" in my code.Let me know what you think.
The text was updated successfully, but these errors were encountered: