Localize enum in PropertyEditor?

Aug 7, 2012 at 6:08 PM

Enums don't appear to be localizable via the LocalizationService (the way pretty much everything else in the PropertyEditor can be localized).

Am I missing something?

Does anyone know a way to localize enums in the PropertyEditor?

(I am using the December 2011 version. If the two updates since then address this that would be cool!)

Aug 8, 2012 at 5:50 PM

I just downloaded the latest source from June 26, 2012, and tried the PropertyControl. I extended the CustomFactoryDemo to add an enum. The enum values there are also not part of the localization pipeline. The demo adds an * to values to show they have been localized. Only the label for the enum gets localized. Does anyone have any solution for localizing enums in PropertyTools?

Aug 8, 2012 at 6:38 PM

I've also tried adding a type converter to the enum (a la Grant Frisken's Localizing .NET Enums), but the type converter doesn't every get called.

Here's the modified class from the CustomFactoryDemo:

    public class TestObject
    {
        public string Title { get; set; }

        [Important]
        public Range Range1 { get; set; }

        public Range Range2 { get; set; }

		public InterfaceDirection Direction { get; set; }

		[TypeConverter(typeof(LocalizedEnumConverter))]
		public enum InterfaceDirection
		{
			None,
			Unidirectional,
			Bidirectional
		}
	}

The LocalizedEnumConverter never gets called.

Am I left with modifying the library source? Any suggestions?

Coordinator
Aug 9, 2012 at 12:16 AM

I have used the "DescriptionConverter" property of the RadioButtonList to implement localized enum descriptions. Create a converter that converts the enum value to a string.

You need to override the CreateEnumControl method in the 'PropertyControlFactory' to set this property.

Will make a full localization example later!

Aug 9, 2012 at 1:28 AM
Can't wait to try it tomorrow!

From: objo [notifications@codeplex.com]
Sent: Wednesday, August 08, 2012 4:16 PM
To: Jon Tindel
Subject: Re: Localize enum in PropertyEditor? [propertytools:390603]

From: objo

I have used the "DescriptionConverter" property of the RadioButtonList to implement localized enum descriptions. Create a converter that converts the enum value to a string.

You need to override the CreateEnumControl method in the 'PropertyControlFactory' to set this property.

Will make a full localization example later!

Sep 4, 2012 at 7:37 PM

This worked great!. But it only works for enums when they are displayed as radio buttons. Is there an alternative that might work for when the radio button threshold is exceeded and you get a ComboBox instead? ComboBox doesn't have DescriptionConverter. (DescriptionConverter is a method on RadioButtonList.)