This post would demo how to do internationalization with springboot and thymeleaf:
2. Environments
SpringBoot 2
Thymeleaf 3
The dependency in maven’s pom.xml
3. The example code
3.1 Add configuration bean
You must have a configuration bean to set some configs in springboot:
3.2 Add message properties file
Add these files to src/main/resources:
Pay attention to the file name prefix, it must be the same as the basename defined in the above messageSource code.
And define a message in the message.properties
3.3 Use the message in thymeleaf code
Then everything is done.
4. Summary
Implement the Internationalization with springboot and thymeleaf is very easy, just be careful with the message file name and the basename of the messageSource definition.