Messages
<th th:text="#{seedstarter.features}">Features</th>
we already defined a MessageSource bean in our spring XML configuration ( MessageSource objects are the standard way of managing externalized texts in Spring MVC):
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="Messages" />
</bean>
…and that basename property indicates that we will have files like Messages_es.properties or Messages_en.properties in our classpath. Let’s have a look at the Spanish version:
seedstarter.datePlanted=Fecha de plantación
seedstarter.covered=Cubierto
seedstarter.type=Tipo
Man kann Messages auch kombinieren. Wenn man zum Beispiel die folgenden Messages hat:
seedstarter.type.WOOD=Madera
seedstarter.type.PLASTIC=Plástico
Kann man auch so darauf zugreifen:
<td th:text="#{${'seedstarter.type.' + sb.type}}">Wireframe</td>
Eine Liste mit mehreren Messages (Enum) ausgeben:
<td th:text="${#strings.arrayJoin(
#messages.arrayMsg(
#strings.arrayPrepend(sb.features,'seedstarter.feature.')),
', ')}">Electric Heating, Turf</td>