I\'m trying to make a multilanguage application using Spring boot and Thymeleaf.
I made few properties files to save the different messages but I\'m only able to display
Your application should extends WebMvcConfigurerAdapter
@SpringBootApplication
public class NerveNetApplication extends WebMvcConfigurerAdapter {
public static void main(String[] args) {
SpringApplication.run(NerveNetApplication.class, args);
}
@Bean
public LocaleResolver localeResolver() {
return new CookieLocaleResolver();
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
lci.setParamName("lang");
return lci;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
}
Then on browser you can switch language with param lang Example: http://localhost:1111/?lang=kh which messages_kh.properites will store the content of Khmer language.