Reputation: 1414
In my current rest-service scenario I need to be able to provide localized error messages to individual clients.
Think of a method like void validate(Locale locale)
which is called on the parameter object when receiving some request.
The locale information can be squeezed out of the http headers.
How can I instruct/configure a validator to use a certain language when violation messages are getting interpolated?
As far as I know a validator chooses the used Locale by calling Locale.getDefault()
.
So far I couldn't find anything other than this article which does not exactly fit to my needs (a story too long to tell).
Thanks in advance!
Upvotes: 1
Views: 3095
Reputation: 7868
According to the spec you have two possibilities:
Use interpolate(String, Context, Locale)
or
implement a custom message interpolator.
A custom message interpolator may be provided (e.g., to interpolate contextual data, or to adjust the default Locale used).
See also:
Upvotes: 4