[jboss-user] [JBoss Seam] - Re: Plurals
petemuir
do-not-reply at jboss.com
Mon Dec 4 18:29:24 EST 2006
At least in English there are so many irregular plurals (e.g. dog/dogs, sheep/sheep, pony/ponies) that I think you would need to specify the messages.
I think you would hit problems parsing that last string. Perhaps its not quite what you are after but I would suggest just using (if you are using facelets) something like
...
| <h:outputText value="#{messages[my:pluraliser('found_targets', foundTargets.rowCount)}" />
| ...
public static String pluraliser(String messageBase, Integer rowCount) {
| if (rowCount == null || rowCount.equals(0)) {
| then return messageBase + "_none";
| } else if (rowCount.equals(1) {
| return messageBase + "_one";
| } else {
| return messageBase + "many";
| }
| }
N.B. You might have to play around with the exact signature of the facelets function - I'm not sure whether you can return the result of a function as the key of map (but if you can't you probably should be able to). If you can't you could wrap it in a facelets source file with an inital ui:param or just lookup the message from Messages.instance() in the facelets function.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991150#3991150
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991150
More information about the jboss-user
mailing list