Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internationalised labels in JSF/Facelets

Does Facelets have any features for neater or more readable internationalised user interface text labels that what you can otherwise do using JSF?

For example, with plain JSF, using h:outputFormat is a very verbose way to interpolate variables in messages.

Clarification: I know that I can add a message file entry that looks like:

label.widget.count = You have a total of {0} widgets.

and display this (if I'm using Seam) with:

<h:outputFormat value="#{messages['label.widget.count']}">
   <f:param value="#{widgetCount}"/>
</h:outputFormat>

but that's a lot of clutter to output one sentence - just the sort of thing that gives JSF a bad name.

like image 300
Peter Hilton Avatar asked Sep 17 '08 18:09

Peter Hilton


1 Answers

Since you're using Seam, you can use EL in the messages file.

Property:

label.widget.count = You have a total of #{widgetCount} widgets.

XHTML:

<h:outputFormat value="#{messages['label.widget.count']}" />

This still uses outputFormat, but is less verbose.

like image 152
Sietse Avatar answered Oct 03 '22 00:10

Sietse