Reputation: 183
I have a simple default application with Spring Boot 1.5.9 and thymeleaf and i'm trying to load the messages from internationalized bundles (messages.properties, messages_XX.properties). Spring Boot only works with the messages.properties files, everytime i change the locale to something like "en" it should look for a file named messages_en.properties but it does not find them. What am i doing wrong? i don't get it, i searched the documentation and it should work.
i have the follow folder structure (pretty basic):
src/main/resources/messages.properties
src/main/resources/messages_en.properties
thank you.
Upvotes: 2
Views: 5241
Reputation: 5703
Created beans in any configuration file
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("message");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver sessionLocaleResolver = new SessionLocaleResolver();
sessionLocaleResolver.setDefaultLocale(Locale.ENGLISH);
return sessionLocaleResolver;
}
Upvotes: 4