Fabrik.Common
Fabrik.Common copied to clipboard
Localization in (Enum)CheckBoxListFor?
I've started using CheckBoxListFor and it's a life saver! Today, I was searching for a way to apply localization. In specific, I am looking to localize enum values.
Is there a built-in way to do this with EnumCheckBoxListFor?
For example, given that I have the following enum:
public enum SomethingEnum
{
[Display(Name = "Een")] // Dutch, but I want to introduce English and Dutch as localization options.
ONE,
[Display(Name = "Twee")]
TWO,
[Display(Name = "Drie")]
THREE
}
I've tried in two ways:
@Html.EnumCheckBoxListFor(model => model.SelectableSomethingEnums)
and
@Html.CheckBoxListFor(model => model.SelectedSomething, new SelectList(Model.SelectableSomethings, "Id", "Type"))
My ViewModel is something like this:
public class ViewModel
{
// For use with CheckBoxListFor
public IEnumerable<Something> SelectableSomethings { get; set; }
public int SelectedSomething{ get; set; }
// For use with EnumCheckBoxListFor
public IEnumerable<SomethingEnum> SelectableSomethingEnums{ get; set; }
}
public class Something
{
internal Something() { }
public int Id { get; internal set; }
public SomethingEnum Type { get; internal set; }
}
Is localization of enums currently supported? If so, in what way? If not, will it be added? :)