我使用 Pluralizer 是否错误?
Paging Jay Querido...
下载了 Pluralizer NuGet 包。我的目标是显示如下字符串:
与 Z 个国家/地区的 Y 合作伙伴签订 X 份合同
如果 X 为 1,则单词应更改为合同。如果 Z 为 1,则单词应更改为国家/地区。 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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来我的评论掩盖了下划线。只需调用 Pluralize 即可实现:
It looks like my comment obscured an underscore. This works with a single call to Pluralize: