messages.properties
messages_en.properties
messages_fr.properties
...
header.label.title=Title
messages.basename.path=D:/project/messages/messages
@Value("${messages.basename.path}")
private String messagesBasename;
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setFallbackToSystemLocale(false);
messageSource.setBasenames("file:" + messagesBasename);
return messageSource;
}
<p th:text="#{header.label.title}">Title</p>