So I'm trying to create another .property file (called labels.properties) that i can use in Thymeleaf like this:
<div th:text=#{property.from.labels}></div>
Right now I just add labels.properties in the root of resource folder, for now its not working. The purpose of this is I want to separate the property file that handles the error messages from texts for labels & buttons.
You can customize the naming (and location) of the message bundles by configuring the spring.messages.basename
property. For example:
spring.messages.basename=labels
By doing so, Spring will look for messages within classpath:labels.properties
and classpath:labels_{locale}.properties
, such as classpath:labels_ja.properties
.
If you want to use this in addition to the regular messages.properties
file, you can use a comma separated value:
spring.messages.basename=messages,labels
The first one within that comma separated list will take priority over the other ones. If you have a property.from.labels
in both messages.properties
and labels.properties
, the one within messages.properties
would be chosen in this example.
This can also be found within the Spring Boot Reference Documentation at the Internationalization section.