Currently I'm using Spring-boot + Thymeleaf and multiple languages. I can't find any easy way to use ICU4j with these. Essentially, as I get it, all what is need is to replace ResourceBundleMessageSource
and its MessageFormat
with the ICU4J variant. But I can't make it work together.
Maybe there is some examples of such projects or any other examples of pluralization functionality in Spring (such as this).
With the typical Spring Boot 2 + Thymeleaf project it can be achieved with this project and the following config:
You also need to add the ICU4J dependency from the maven.
In your messages.properties (messages_ru.properties in my case):
Using:
If you have troubles with finding messages.properties end getting errors like
??plural_ru??
, check your location and names for these filesmessageSource.setBasename("classpath:messages/messages")
.