'Humanizer Pluralize/Singularize to indicate Is/Are based on the collection size
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
Solution 1:[1]
There might be a cleaner way to do it with Humanizer but I haven't found it. This works though:
$"There {qty} {"are".ToQuantity(qty, ShowQuantityAs.None)} conflicting {"schedule".ToQuantity(qty, ShowQuantityAs.None)}."
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steve Dowling |
