title: How to translate Identity Password validation messages
body: <p>So far I have been able to translate everything in an ASP.Net Core 2.1 Web Application.</p>
  
  <p>It has proven a little challenge, since the scaffolded Account Pages needed a little setup.</p>
  
  <p>But what I cannot find is a way to translate the Password validation messages.  Also, translating the model binding messages were a little challenge (thanks stackoverflow).</p>
  
  <p>Any ideas?</p>
  
  <p>I include the relevant parts of my <code>Startup.cs</code> file:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
       ...
  
       services.AddMvc(options =&gt;
       {
           var type = typeof(SharedResources);
           var assemblyName = new AssemblyName(type.GetTypeInfo().Assembly.FullName);
           var factory = services.BuildServiceProvider().GetService&lt;IStringLocalizerFactory&gt;();
           var L = factory.Create("SharedResources", assemblyName.Name);
  
           options.ModelBindingMessageProvider.SetValueIsInvalidAccessor(x =&gt; L["The value '{0}' is invalid.", x]);
           options.ModelBindingMessageProvider.SetValueMustNotBeNullAccessor(x =&gt; L["The value '{0}' is invalid.", x]);
           options.ModelBindingMessageProvider.SetValueMustBeANumberAccessor(x =&gt; L["The field {0} must be a number.", x]);
           options.ModelBindingMessageProvider.SetMissingBindRequiredValueAccessor(x =&gt; L["A value for the '{0}' property was not provided.", x]);
           options.ModelBindingMessageProvider.SetAttemptedValueIsInvalidAccessor((x, y) =&gt; L["The value '{0}' is not valid for {1}.", x, y]);
           options.ModelBindingMessageProvider.SetMissingKeyOrValueAccessor(() =&gt; L["A value is required."]);
           options.ModelBindingMessageProvider.SetUnknownValueIsInvalidAccessor(x =&gt; L["The supplied value is invalid for {0}.", x]);
           options.ModelBindingMessageProvider.SetMissingRequestBodyRequiredValueAccessor(() =&gt; L["A non-empty request body is required."]);
           options.ModelBindingMessageProvider.SetNonPropertyAttemptedValueIsInvalidAccessor(x =&gt; L["The value '{0}' is not valid.", x]);
           options.ModelBindingMessageProvider.SetNonPropertyUnknownValueIsInvalidAccessor(() =&gt; L["The supplied value is invalid."]);
           options.ModelBindingMessageProvider.SetNonPropertyValueMustBeANumberAccessor(() =&gt; L["NonPropertyValueMustBeNumber"]);
       })
       .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
       .AddDataAnnotationsLocalization(options =&gt;
          {
              options.DataAnnotationLocalizerProvider = (type, factory) =&gt;
              {
                  // This is for Account scaffolded pages data annotations
                  return factory.Create(typeof(SharedResources));
              };
          });
  
       ...
  
  }
  </code></pre>
  
  <p>I cannot put something like this in the <code>InputModel</code> of <code>Register.cshtml.cs</code> because the <code>ErrorMessage</code> gets ignored (and I won't do it anyways, since I don't want to hardcode the password policy description):</p>
  
  <pre><code>        [Required(ErrorMessage = "The {0} field is required.")]
          [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
          [DataType(DataType.Password, ErrorMessage = "Password must be nice")]
          [Display(Name = "Password")]
          public string Password { get; set; }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/GY2gs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GY2gs.png" alt="Screenshot of translated registration page"></a></p>