views:

100

answers:

6

Hi, I've got Enum:

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

+1  A: 

Need more details on how you want to implement it. Based on current information, there are hundreds of ways to do it. You might want to narrow down the problem definition.

Nayan
This should be a comment, not an answer.
Marcelo Cantos
How much rep do you need to comment?
Daren Thomas
I don't have rep enough to put as comment.But anyway, the question is not descriptive enough.
Nayan
+12  A: 

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
+2  A: 

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
A: 

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
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
A: 

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

Sergey Osypchuk