Girders extends the support of Spring Boot I18N and MessageSource
with a MessageSourceDecorator
that provides
additional functionality for tracing and debugging I18N issues.
Add the module by including the following dependency in your POM:
<dependency>
<groupId>com.netcetera.girders</groupId>
<artifactId>girders-starter-i18n</artifactId>
</dependency>
The following Spring beans are exposed by the Girders I18N module:
Bean | Description |
---|---|
messageSource | An instance of MessageSourceDecorator which wraps the Spring's MessageSource that is auto-configured by Spring Boot. |
You can use all the configuration properties for the standard Spring Boot MessageSource
. In addition, the Girders
MessageSourceDecorator
provides the following properties:
Property | Default | Description |
---|---|---|
girders.i18n.appendCode | false | Append the message code to the resolved text. This should probably only be used during development. |
The Girders MessageSourceDecorator
logs lookups of messages with level TRACE
into the following logger:
com.netcetera.girders.i18n.MessageSourceDecorator
At development time, Girders recommends using
Netcetera Trema
for the management of text resources. The text property files can be generated automatically during the build
process using this snippet in the pom.xml
file of the module:
<plugin>
<groupId>com.netcetera.trema</groupId>
<artifactId>trema-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>exportProperties</goal>
</goals>
<configuration>
<tremaFile>${basedir}/src/main/resources/messages.trm</tremaFile>
<basename>${project.build.directory}/classes/messages</basename>
<languages>
<language>en</language>
<language>de</language>
</languages>
<!--
default language must be defined for Spring Boot to have a default message.properties on the classpath
which triggers the auto configuration
-->
<defaultlanguage>en</defaultlanguage>
</configuration>
</execution>
</executions>
</plugin>