How do you localize enums for a ListBoxFor where multiple options are possible?
For example an enum that contains roles:
pu
I solved the issue by creating a EnumExtension which I use in my view. This extension looks for a resource file called "EnumResources.resx" and looks up the resource by the following naming convention {Name of EnumType}_{Value of enum passed in}. If the resource key is missing it will display the value of the resource encapsulated within double brackets [[EnumValue]]. This way its easy to find a "untranslated" Enum in your view. Also this helps reminding you if you forgot to update the resource file after a rename or such.
public static class EnumExtensions
{
public static string GetDisplayName(this Enum e)
{
var rm = new ResourceManager(typeof (EnumResources));
var resourceDisplayName = rm.GetString(e.GetType().Name + "_" + e);
return string.IsNullOrWhiteSpace(resourceDisplayName) ? string.Format("[[{0}]]", e) : resourceDisplayName;
}
}
The resource file looks like this:

Usage:
@ContractStatus.Created.GetDisplayName()