Как вы локализуете перечисления для ListBoxFor
, где возможны несколько вариантов?
Например, enum
, который содержит роли:
public enum RoleType
{
[Display(Description = "Administrator", ResourceType = typeof(Resource))]
Administrator = 1,
[Display(Description = "Moderator", ResourceType = typeof(Resource))]
Moderator = 2,
[Display(Description = "Webmaster", ResourceType = typeof(Resource))]
Webmaster = 3,
[Display(Description = "Guest", ResourceType = typeof(Resource))]
Guest = 4,
Etc.... = 5,
}
Я видел это с помощью dropdownlist
/selectlists
. Но есть ли способ сделать это для нескольких избранных списков?
[EDIT]
Вот как я хотел бы использовать его, вот как он работает сейчас, но не переводится на другой язык:
var roles = from role r in Enum.GetValues(typeof(RoleType))
select new
{
Id = (int)Enum.Parse(typeof(RoleType), r.ToString()),
Name = r.ToString()
};
searchModel.roles = new MultiSelectList(roles, "Id", "Name");
Примечание. Я переименовал enum из Role в RoleType.