I have a MVC 5 project and need to set entire project to pt-BR culture/language. I want all messages (jQuery validation) like "The field X is required" to be translated to portuguese. (Other languages will not be supported)
Debugging the project in localhost, the message appears in portuguese, however after deploy to Azure, the messages appears in English (I tested opening the site in PC and Android mobile).
I have tried:
add the following line to "system.web" section in web.config:
< globalization culture="pt-BR" uiCulture="pt-BR" />
install the Globalize NuGet package and run the following script:
Globalize.Culture('pt-BR');
set default model binder to use custom resources:
ClientDataTypeModelValidatorProvider.ResourceClassKey = "CustomResources"; DefaultModelBinder.ResourceClassKey = "CustomResources";
and in App_GlobalResources\CustomResources.pt-BR.resx add the following:
Name Value PropertyValueRequired Preenchimento obrigatório.
I read about using ErrorMessageResourceName and ErrorMessageResourceType in RequiredAttribute (DataAnnotations), but for this I need to change all properties in model with this parameters, however what I want is only change the default message "The field X is required" to all fields marked with the "[Required]" attribute.