Humanizer Pluralize/Singularize to indicate Is/Are based on the collection size

899 Views Asked by At

How can I singularize or pluralize a string with the words is or are based on a collection size. For example I would like to notify users about a conflict in a scheduling, And there could be 1 or more conflicts. So based on the amount of conflicts I would like to Humanize the string.

e.g When there is 1 conflict I would like to show There is {#} conflicting schedule.

e.g When there are more then 1. I would like to say There are {#} conflicting schedules.

You can see the 2 differences between the strings are the words Are/is and S at the end of schedules

1

There are 1 best solutions below

2
On

There might be a cleaner way to do it with Humanizer but I haven't found it. This works though:

$"There {"are".ToQuantity(qty, ShowQuantityAs.None)} {qty} conflicting {"schedule".ToQuantity(qty, ShowQuantityAs.None)}."