1

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)
Charles
  • 50,943
  • 13
  • 104
  • 142
danludwig
  • 46,965
  • 25
  • 159
  • 237
  • As soon as I post I find the answer. Seems this works: `@Html.Pluralize("{0|_} {0|contract} with {1|_} {1|partner} in {2|_} {country}", Model.TotalContracts, Model.TotalPartners, Model.TotalCountries)` – danludwig Dec 20 '11 at 17:30

1 Answers1

1

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)
danludwig
  • 46,965
  • 25
  • 159
  • 237