You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
}
@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? :)
The text was updated successfully, but these errors were encountered:
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:
I've tried in two ways:
and
My ViewModel is something like this:
Is localization of enums currently supported? If so, in what way? If not, will it be added? :)
The text was updated successfully, but these errors were encountered: