1

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

user278618
  • 19,306
  • 42
  • 126
  • 196
  • If you are using WPF you could make a converter that took care of "translating" the enum members to a proper name, just a tip. – Skurmedel Apr 14 '10 at 09:42
  • as you are no doubt finding out in the responses you are getting, `enum `abuse is a serious social issue and is treated as such by the programming community. please seek help: http://msdn.microsoft.com/en-us/library/aa309421(VS.71).aspx – Sky Sanders Apr 18 '10 at 08:28

5 Answers5

12

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.

Matti Virkkunen
  • 63,558
  • 9
  • 127
  • 159
2

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.

Prutswonder
  • 9,894
  • 3
  • 27
  • 39
0

What about a solution like this?

public enum ObjectType 
{ 
    Country=0,
    Land=0, 
    Region=1, 
    ...
} 

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.

NinethSense
  • 8,824
  • 2
  • 23
  • 23
  • How would the client know which values to show and which to hide? ...as you and others mention, don't put localization in the enum. It just not works. – Peter Lillevold Apr 14 '10 at 10:02
0

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

st78
  • 8,028
  • 11
  • 49
  • 68
0

there is the answer:

Can my enums have friendly names?

Community
  • 1
  • 1
user278618
  • 19,306
  • 42
  • 126
  • 196