I had a problem some time ago about localizing enum values, I'm not sure if it answers your question, but at least gives you a different approach that you need to keep in mind.
Start creating your own Localizing attribute
From there I create enum myself
[TypeConverter(typeof(EnumToLocalizedString))] public enum ReviewReason { [LocalizationAttribute("ReviewReasonNewDocument")] NewDocument = 1, [LocalizationAttribute("ReviewReasonInternalAudit")] InternalAudit = 2, [LocalizationAttribute("ReviewReasonExternalAudit")] ExternalAudit = 3, [LocalizationAttribute("ReviewReasonChangedWorkBehaviour")] ChangedWorkBehaviour = 4, [LocalizationAttribute("ReviewReasonChangedWorkBehaviourBecauseOfComplaints")] ChangedWorkBehaviourBecauseOfComplaints = 5, [LocalizationAttribute("ReviewReasonMovedFromOlderSystem")] MovedFromOlderSystem = 6, [LocalizationAttribute("ReviewReasonPeriodicUpdate")] PeriodicUpdate = 7, [LocalizationAttribute("ReviewReasonDocumentChanged")] DocumentChanged = 8 }
Then I created a type converter that will extract the LocalizationAttribute description key and access the resource file in order to get localization (the attribute description must match the resource key :))
public class EnumToLocalizedString : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return (sourceType.Equals(typeof(Enum))); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return (destinationType.Equals(typeof(String))); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (!destinationType.Equals(typeof(String))) { throw new ArgumentException("Can only convert to string.", "destinationType"); } if (!value.GetType().BaseType.Equals(typeof(Enum))) { throw new ArgumentException("Can only convert an instance of enum.", "value"); } string name = value.ToString(); object[] attrs = value.GetType().GetField(name).GetCustomAttributes(typeof(LocalizationAttribute), false); if (attrs.Length != 1 !(attrs[0] is LocalizationAttribute)) { throw new ArgumentException("Invalid enum argument"); } return Handbok.Code.Resources.handbok.ResourceManager.GetString(((LocalizationAttribute)attrs[0]).Description); } }
Finally, I created a client that uses TypeConverter, which in this case is a collection
public class ReviewReasonCollection { private static Collection<KEYVALUEPAIR<REVIEWREASON,>> _reviewReasons; public static Collection<KEYVALUEPAIR<REVIEWREASON,>> AllReviewReasons { get { if (_reviewReasons == null) { _reviewReasons = new Collection<KEYVALUEPAIR<REVIEWREASON,>>(); TypeConverter t = TypeDescriptor.GetConverter(typeof(ReviewReason)); foreach (ReviewReason reviewReason in Enum.GetValues(typeof(ReviewReason))) { _reviewReasons.Add(new KeyValuePair<REVIEWREASON,>(reviewReason, t.ConvertToString(reviewReason))); } } return _reviewReasons; } } }
I originally posted this solution on my blog . Hope this helps you :)