Reputation: 47375
Paging Jay Querido...
Downloaded the Pluralizer NuGet package. My goal is to display a string like so:
X contracts with Y partners in Z countries
If X is 1, word should change to contract. If Z is 1, word should change to country. Same for 1 partner.
The following does not work. It always results in TotalContracts being the same number for the whole sentence.
@Html.Pluralize("{_} {contract} with {_} {partner} in {_} {country}",
Model.TotalContracts, Model.TotalPartners, Model.TotalCountries)
@* result is X contracts with X partners in X countries *@
The following does work, but is not quite as readable. Is there a better way?
@Html.Pluralize("{_} {contract}", Model.TotalContracts) with
@Html.Pluralize("{_} {partner}", Model.TotalPartners.Count) in
@Html.Pluralize("{_} {country}", Model.TotalCountries)
Upvotes: 1
Views: 288
Reputation: 47375
It looks like my comment obscured an underscore. This works with a single call to Pluralize:
@Html.Pluralize("{0|_} {0|contract} with {1|_} {1|partner} in {2|_} {country}",
Model.TotalContracts, Model.TotalPartners, Model.TotalCountries)
Upvotes: 1