Does Hibernate validators supports internationalization. I saw the jar and I could see the various ValidationMessages.properties file.
Can we create our own custom error messages which will be internationalized? I don't want to use error messages provided by default in Hibernate validators.
We need to use our own custom message and they should be internationalized.
As well what are the languages supported by the Hibernate validators. In jar I saw properties files for the English, French, German, Turkish and Mongolian.
Can we add some more languages e.g. Spanish, Portuguese etc?
I18N is integral part of the Bean Validation specification.
By default messages are retrieved from a resource bundle named "ValidationMessages". So just provide this bundle (e.g. ValidationMessages.properties) for the language(s) you need to override the default messages from Hibernate Validator (which are retrieved from the bundle "org.hibernate.validator.ValidationMessages").
Besides the languages you mentioned Hibernate Validator 4.2 will provide Chinese (HV-359) and Spanish (HV-483) messages.
If you don't want to work with file based resource bundles at all you also can provide your own MessageInterpolator or ResourceBundleLocator implementations.
Using Hibernate Validator's PlatformResourceBundleLocator
it's also possible to use bundles with other names than "ValidationMessages" like this:
Validation
.byProvider(HibernateValidator.class)
.configure()
.messageInterpolator(
new ResourceBundleMessageInterpolator(
new PlatformResourceBundleLocator("com.mycompany.Messages")))
.buildValidatorFactory()
.getValidator();`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With