如何让我的 Web 应用程序理解单数和复数之间的区别?

发布于 2024-11-08 23:21:42 字数 200 浏览 0 评论 0 原文

当热门网站上的用户收到回复时,他们(相当尴尬地)被告知他们有“1 个回复”(参见插图)。

我相信一定很容易确定他们是否有一个回复 /em> 并去掉单词末尾的“s”。

When a user on a popular website gets a response, they are (rather embarrassingly) told that they have "1 responses" (see illustration).

"1 responses"? Embarrassing

I'm sure it must be easy to determine whether they have one response and strip the 's' from the end of the word.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

卖梦商人 2024-11-15 23:21:42

对于英语来说,这通常并不比以下困难:

if number == 1:
    print "1 response"
else:
    print "%s responses" % number

对于其他口语来说,这可能相当困难,因为它并不总是只是附加一个 s 的问题。不过,技术保持不变。您必须添加代码来检查号码并显示正确的表格。

通常,我会使用完全不同的措辞来表示零(“您没有响应”)、1(“您只有一个响应”)或 2+(您有 N 个响应)。显然,在您给出的具体示例中,这并不适用。

然而,在您给出的具体示例中,人们可能会认为实现是正确的。它是带有数字标记的“响应”选项卡。这不是一个英文句子,而是一个选项卡的名称。因此,无论有多少回复,它始终是“回复”选项卡。不过,这有点让人恼火,我想如果这是我的网站,我可能会将其更改为“1 个响应”。

For the English language it's generally no more difficult than:

if number == 1:
    print "1 response"
else:
    print "%s responses" % number

For other spoken languages it can be rather difficult because it's not always a matter of just appending an s. The technique remains the same, though. You have to add code to check the number and display the proper form.

Often I'll use completely different wording for the case of zero ("you have no responses"), 1 ("you have only one response") or 2+ (you have N responses). Obviously, in the specific example you give that doesn't apply.

In the specific example you give, however, one could argue that the implementation is correct. It is the "responses" tab with a marker for the number. It's not an English sentence but rather the name of a tab. So, no matter how many responses there are, it will always be the "responses" tab. That's splitting a fine hair though, and I think if this were my website I would probably change it to "1 response".

原谅我要高飞 2024-11-15 23:21:42

这取决于您使用的语言/框架。
例如,Rails 中有一个pluralize 帮助器,它提供:

pluralize(1, 'response') => "1 response"
pluralize(2, 'response') => "2 responses"

It depends on the language/framework you are using.
For example, in Rails there is a pluralize helper, which gives:

pluralize(1, 'response') => "1 response"
pluralize(2, 'response') => "2 responses"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文