I’m working on asp.net mvc web site Localization and I’ve faced problems with enums translation.
I need code like this:
public enum PossibilityEnum
{
[LocalDescription(CultureCode=UserLoginInfo.UserLang, ResourceKey="ProjectDelete")]
ProjectDelete,
[LocalDescription(CultureCode=UserLoginInfo.UserLang, ResourceKey="ProjectCreate")]
ProjectCreate,
[LocalDescription(CultureCode=UserLoginInfo.UserLang, ResourceKey="ProjectEdit")]
ProjectEdit
}
UserLoginInfo is my custom class, where I have all info about user.
Is it possible? And how can I make it?
Edit
UserLoginInfo has property
public LangType UserLang { get { return LangType.Eng; } }
public enum LangType
{
[Tag(TagType.Culture, "ru-RU")]
Rus = 1,
[Tag(TagType.Culture, "en")]
Eng = 2,
}
Remember that your View is just a means of presenting data to your user.
Although the enum is used within the code, you shouldn’t be using a parsed version of your enum as text on your View. Instead use it to select a string resource, which can easily be translated.