Can I localize [Display] attribute text for an Enum, and if so, how would I get Localize T into my .cs file?

Topics: Localization, Troubleshooting, Writing modules
Nov 29, 2012 at 2:36 PM

I placed several Enum's in a file under my Model Namespace:

public enum One {...}

public enum Two {...}

public enum Three{...}

public enum Four{...}

The Enum's have a [Display(Name="Text")] attribute that I was thinking to localize using T().

Looking at other modules, I notice that you need to do something like this to get localization:

        private readonly IOrchardServices _orchardServices;
        public Localizer T { get; set; }

        public Class
            IOrchardServices orchardServices,
            _orchardServices = orchardServices;
            T = NullLocalizer.Instance;

Thing is my Enum.cs file doesn't have a "class", it just has all my Enum's. Any thought's on how I might accomplish this?

Nov 29, 2012 at 6:00 PM

I'm not sure enums can be localizable by themselves. There are alternatives however, such as properties on a class that return a localizable string.