Would it be possible to change literals in the model below to reference values from an external file for localization or quick user changes?
Given users who change their minds a thousand times. How could I change the literals below to come from a config file or something similar?
namespace mvc3test.Models
{
public class ChangePasswordModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumL开发者_运维百科ength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
These attributes(eg DisplayAttribute) have ResourceType
and Name
properties. These can be used with a Resource file to externalize the literals and thereby localizing and/or changing literals. Have a look at this example.
精彩评论