Paging Jay Querido ......
下载了Pluralizer NuGet包。我的目标是显示如下字符串:
X与Z国家/地区的Y合作伙伴签订合同
如果X为1,则单词应更改为合同。如果Z为1,则单词应更改为country。 1个合作伙伴也一样。
以下不起作用。它总是导致TotalContracts与整个句子的数字相同。
@Html.Pluralize("{_} {contract} with {_} {partner} in {_} {country}",
Model.TotalContracts, Model.TotalPartners, Model.TotalCountries)
@* result is X contracts with X partners in X countries *@
以下确实有效,但不太可读。还有更好的方法吗?
@Html.Pluralize("{_} {contract}", Model.TotalContracts) with
@Html.Pluralize("{_} {partner}", Model.TotalPartners.Count) in
@Html.Pluralize("{_} {country}", Model.TotalCountries)
答案 0 :(得分:1)
看起来我的评论模糊了一个下划线。这适用于对Pluralize的单次调用:
@Html.Pluralize("{0|_} {0|contract} with {1|_} {1|partner} in {2|_} {country}",
Model.TotalContracts, Model.TotalPartners, Model.TotalCountries)