networknt / json-schema-validator

A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
Apache License 2.0
822 stars 323 forks source link

SchemaValidatorConfig.setLocale(ENGLISH) does not work when running from non-english environments #949

Closed mayconcomput closed 7 months ago

mayconcomput commented 7 months ago

Issue:

When validation erros are resolved for a non-english running environment, let's say for instance German, validation messages will arrive in German even when SchemaValidatorConfig is set to English locale.

Reason:

The jsv-messages.properties is by default english, but there is jsv-messages_en<_US>.properties

How to Reproduce:

  1. Set Globaly the Locale to German (e.g: Locale.setDefault(Locale.GERMAN) to simulate a an environment running with non-english language
  2. Configure the custom locale (e.g.: SchemaValidatorConfig.setLocale(Locale.ENGLISH)
  3. Expected english messages but will get german messages

Suggested solution

Create an empty resource bundle named jsv-messages_en.properties