JSF supports internationalization of user interface labels and descriptive text via the use of <f:loadBundle />
. You can use this approach in Seam applications. Alternatively, you can take advantage of the Seam messages
component to display templated labels with embedded EL expressions.
Each login session has an associated instance of java.util.ResourceBundle
(available to the application as a session-scoped component named org.jboss.seam.core.resourceBundle
). You'll need to make your internationalized labels available via this special resource bundle. By default, the resource bundle used by Seam is named messages
and so you'll need to define your labels in files named messages.properties
, messages_en.properties
, messages_en_AU.properties
, etc. These files usually belong in the WEB-INF/classes
directory.
So, in messages_en.properties
:
Hello=Hello
And in messages_en_AU.properties
:
Hello=G'day
You can select a different name for the resource bundle by setting the Seam configuration property named org.jboss.seam.core.resourceBundle.bundleNames
. You can even specify a list of resource bundle names to be searched (depth first) for messages.
<core:resource-bundle>
<core:bundle-names>
<value>mycompany_messages</value>
<value>standard_messages</value>
</core:bundle-names>
</core:resource-bundle>
If you want to define a message just for a particular page, you can specify it in a resource bundle with the same name as the JSF view id, with the leading /
and trailing file extension removed. So we could put our message in welcome/hello_en.properties
if we only needed to display the message on /welcome/hello.jsp
.
You can even specify an explicit bundle name in pages.xml
:
<page view-id="/welcome/hello.jsp" bundle="HelloMessages"/>
Then we could use messages defined in HelloMessages.properties
on /welcome/hello.jsp
.