abp icon indicating copy to clipboard operation
abp copied to clipboard

How to change validation localization?

Open wingqing1314 opened this issue 6 years ago • 5 comments

Please check the official documentation before asking questions: https://docs.abp.io/en/abp/latest/Localization

I followed the documentation and it didn't work image image image image

Originally posted by @wingqing1314 in https://github.com/abpframework/abp/issues/4199#issuecomment-638139275

wingqing1314 avatar Jun 03 '20 12:06 wingqing1314

image It works after added ErrorMessage . It has to be ,right?

wingqing1314 avatar Jun 03 '20 12:06 wingqing1314

What is the value of CultureInfo.CurrentUICulture Make sure your current UI culture is zh-hans.

realLiangshiwei avatar Jun 03 '20 12:06 realLiangshiwei

What is the value of CultureInfo.CurrentUICulture Make sure your current UI culture is zh-hans.

I just want the response message is in Chinese, not displayed on UI.

wingqing1314 avatar Jun 03 '20 14:06 wingqing1314

Please see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.1 learn about localization in ASP.NET Core.

realLiangshiwei avatar Jun 04 '20 00:06 realLiangshiwei

Please see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.1 learn about localization in ASP.NET Core.

Got it!

public void ConfigureServices(IServiceCollection services)
        {
            services.AddApplication<UserHttpApiHostModule>();
            services.AddMvc()
                    .AddDataAnnotationsLocalization(options =>
                    {
                        options.DataAnnotationLocalizerProvider = (type, factory) =>
                            factory.Create(typeof(UserResource));
                    });
        }

Add this code will be work without ErrorMessage 😀

wingqing1314 avatar Jun 04 '20 01:06 wingqing1314