多个用户消息 [英] Plurality in user messages

查看:129
本文介绍了多个用户消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多时候,产生的信息展现给用户时,该邮件将包含许多的的东西的,我要通知客户。

Many times, when generating messages to show to the user, the message will contain a number of something that I want to inform the customer about.

我来举个例子:客户已经选择了一些项目,从1及以上,并已删除点击。现在我想给一个确认信息给客户,我想提一提,他已经选择了尽量减少他选择了一堆项目,并单击删除时,他只是想删除一个犯错误的机会项目的数量。他们

I'll give an example: The customer has selected a number of items from 1 and up, and has clicked delete. Now I want to give a confirmation message to the customer, and I want to mention the number of items he has selected to minimize the chance of him making a mistake by selecting a bunch of items and clicking delete when he only wants to delete one of them.

的一种方法是使这样的一般消息:

One way is to make the generic message like this:

int noofitemsselected = SomeFunction();
string message = "You have selected " + noofitemsselected + " item(s). Are you sure you want to delete it/them?";



问题这里的情况,其中 noofitemselected 1,我们必须编写的项目的和的的而不是项目的和的他们

The "problem" here is the case where noofitemselected is 1, and we have to write item and it instead of items and them.

我的正常的解决方案将是这样的。

My normal solution will be something like this

int noofitemsselected = SomeFunction();
string message = "You have selected " + noofitemsselected + " " + (noofitemsselected==1?"item" : "items") + ". Are you sure you want to delete " + (noofitemsselected==1?"it" : "them") + "?";

这变得很长,挺讨厌的真快,如果有代码里面的数字多很多参考资料和实际的消息变得难以阅读。

This gets quite long and quite nasty really fast if there are many references to the numbers plurality inside the code, and the actual message gets hard to read.

所以我的问题很简单。有没有产生这样的消息没有更好的方法呢?

So my questions is simply. Are there any better ways of generating messages like this?

修改

我看到很多人已经在我提到该消息应该一个消息框,里面显示,并简单地给出如何避免使用消息框在所有的答案,那就是所有好的情况变得非常挂断了电话。

I see a lot of persons has got very hung up in the case that I mentioned that the message should be displayed inside a message box, and has simply given an answer of how to avoid using the message box at all, and that is all good.

但请记住,多元化的问题也适用于文本等地的项目,除了消息框。例如,一个标签一起显示在网格选择将关于复数同样的问题的行数的网格。

But remember that the problem of pluralization also apply to texts other places in the program in addition to message boxes. For example, a label alongside a grid displaying the number of lines selected in the grid will have the same problem regarding pluralization.

因此​​,这基本上适用于大部分的文本被输出从方案的一些方式,然后将溶液并不是那么简单,只需更改程序不输出文本了:)

So this basically apply to most text that is outputted in some way from programs, and then the solution is not as simple as to just change the program to not output text anymore :)

推荐答案

如果有过任何机会,不管多么小,这个应用程序将需要被翻译成其他语言则两者都是错误的。这样做的正确的方法是:

If there is ever any chance, no matter how small, that this app will need to be translated to other languages then both are wrong. The correct way of doing this is:

string message = ( noofitemsselected==1 ?
  "You have selected " + noofitemsselected + " item. Are you sure you want to delete it?":
  "You have selected " + noofitemsselected + " items. Are you sure you want to delete them?"
);

这是因为不同的语言处理多个不同。有些人喜欢马来人甚至没有语法复数所以琴弦一般会是相同的。分离这两个字符串可以更容易地支持其他语言以后。

This is because different languages handle plurality differently. Some like Malay don't even have syntactic plurals so the strings would generally be identical. Separating the two strings makes it easier to support other languages later on.

否则,如果该应用旨在通过广大市民要消耗应该是用户友好的话第二种方法是优选的。很抱歉,但我真的不知道这样做的短路。

Otherwise if this app is meant to be consumed by the general public and is supposed to be user friendly then the second method is preferable. Sorry but I don't really know a shorter way of doing this.

如果这个程序是为了被你的公司只国内消费然后执行快捷键项目(S)的事情。你真的没有写enterprisy代码时打动任何人。但我建议不要做这行公开消费应用,因为这给人的印象是程序员懒惰,从而降低他们的应用程序质量的意见。相信我,小东西像这样的事情。

If this app is meant to be consumed only internally by your company then do the shortcut "item(s)" thing. You don't really have to impress anybody when writing enterprisy code. But I'd advise against doing this for publicly consumed app because this gives the impression that the programmer is lazy and thus lower their opinion of the quality of the app. Trust me, small things like this matter.

这篇关于多个用户消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆