This content has been marked as final.
Show 1 reply
-
1. Re: Plurals
pmuir Dec 4, 2006 6:29 PM (in response to jjarkko)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.