meta info

Localized Identity Errors

By Ziya Mollamahmut

All identity errors are localized by XLocalizer with the default setup, so no additional steps required to localize identity errors.

When the source translation culture is "en", no additional setup required for localizing identity error messages, it will be localized automatically by XLocalizer. But if the source translation culture is different than "en", then we have to provide the default identity errors in the relevant default culture, so XLocalizer can use them as source for translation.

Customize identity errors

Model binding errors can be customized by providing a new object of type XLocalizer.ErrorMessages.IdentityErrors into XLocalizerOptions in startup file.

services.AddRazorPages()
        .AddXLocalizer<...>(ops =>
        {
            // ...
            ops.IdentityErrors = new IdentityErrors 
            {
                DuplicateEmail = "Email '{0}' is already taken.",
                DuplicateUserName = "User name '{0}' is already taken.",
                InvalidEmail = "Email '{0}' is invalid.",
                // ...
            };
        });

Same way we can provide the default model binding errors in a different culture other than "en".

Customize via json

See Setup XLocalizer via JSON Settings.