Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization in (Enum)CheckBoxListFor? #41

Open
DianaLaa opened this issue Aug 11, 2017 · 0 comments
Open

Localization in (Enum)CheckBoxListFor? #41

DianaLaa opened this issue Aug 11, 2017 · 0 comments

Comments

@DianaLaa
Copy link

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? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant