枚举的版本
公共枚举对象类型 { 国家/地区=0, 区域=1, 省份=2, 城市=3, 酒店=4 我
有两个具有两种语言版本的应用程序,并且此枚举显示在某个地方,因此取决于语言版本我想
在德语版本中显示正确版本的枚举,而不是乡村土地等。
此应用程序使用相同的网络服务,其中声明了这个枚举。
添加
我有一个 datagridview 和对象列表,其中类具有字段 ObjectType,我必须在 datagridviev 中显示此池,所以这是一个问题
public enum ObjectType
{
Country=0,
Region=1,
Province=2,
City=3,
Hotel=4
}
I have two applications in two language versions, and this Enum is displaying in some place, so depends of language version I wanna displaying correct version of Enum
in german version instead Country Land etc.
This Application are using the same websercice which has declaration of this enum.
ADDED
I have a datagridview and list of objects which classes has field ObjectType and I must display this pool in datagridviev, so it's a problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
枚举键是代码的一部分,就像方法名称一样。它们不应该被本地化。
如果您需要本地化内容,请不要直接向用户显示枚举键。使用资源文件将它们映射到本地化值。
Enum keys are part of your code, just like method names. They're not supposed to be localized.
If you need to localize things, don't display the enum keys to the user directly. Map them to localized values using a resource file.
枚举值应该用于编程逻辑,通常不用于 UI 输出。您应该以默认英语(就像大多数编程关键字一样)提供
ObjectType
枚举,并让 WebService 使用者将其翻译为正确的语言。Enum values are supposed to be for programming logic, and are usually not used for UI output. You should serve the
ObjectType
enum in default English (like most programming keywords are) and let the WebService consumer do the translation to the correct language.像这样的解决方案怎么样?
顺便说一句,正如有人所说,枚举不应该本地化。尝试一些其他好的解决方案。如果您分享更多详细信息,我们会尽力提出建议。
What about a solution like this?
By the way, as someone said, Enums are not supposed to be localized. Try for some other good solution. If you share more details, we will try to suggest.
最好是在枚举和字符串表示之间实现数据库或配置文件映射。它不仅可以帮助您进行本地化,还可以帮助您进行具有两个单词的枚举值
Best would be to implement database or configuration file mapping between enum and string representation. It will help you not only for localisation, but also enum values which hase two words
答案是:
我的枚举可以有友好的名称吗?
there is the answer:
Can my enums have friendly names?