Reputation: 555
I am working on a MVC project. I have model called person whose attributes are Name and Country.
in my model i have used [DisplayName("Name")]
public string Name{ get; set; }
I want that if Country is England DisplayNAme should be Name , if country is Netherlands then Display name should be Naam.
In short can we make DisplayName conditional in model itsefl? or can we assign more than one displayname to attribute??
Upvotes: 1
Views: 3422
Reputation: 18549
Yes, add a resource file for each language with a key of Name. You can then decorate your class Properties with something like this:
[Display(Name = "Name", ResourceType = typeof(MyResources))]
Further details on Display
can be found here, and localization and MVC in general here.
Upvotes: 3