I'm new to spring specially spring boot, i'm trying to use internationalisation, so far i'm using with normal controllers fine, but i can't make it work with Bean Validation using spring-data-rest.
I'm using the following code to start the application:
@EnableJpaRepositories
@SpringBootApplication
@EnableWebMvc
public class Application extends WebMvcConfigurerAdapter {
@Bean(name = "validator")
public LocalValidatorFactoryBean validator() {
return new LocalValidatorFactoryBean();
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
slr.setDefaultLocale(Locale.US);
return slr;
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
lci.setParamName("lang");
return lci;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
}
I can use locale fine with Controllers, but i can't make Bean Validation respect other locales, it always use default locale.
Any help?
I'm using spring-data-rest and spring-boot in version 1.2.5.RELEASE.