On Oct 27, 2010, at 9:19 AM, Michael Pavling wrote:

On 27 October 2010 14:07, Rob Biedenharn <[email protected]> wrote:

If you're just in plain Ruby, it might depend on the pluralization rule:

 "#{n} month#{'s' unless n == 1}"

 "#{n} part#{n == 1 ? 'y' : 'ies'}"

 "#{n} fish"


You can also use String.pluralize
"#{n} {n == 1 ? 'month' : 'month'.pluralize}"

http://apidock.com/rails/ActiveSupport/Inflector/pluralize

True, but my point was that you may not even need the help from ActiveSupport for something simple (i.e., you are dealing with a known rather than an arbitrary noun).

You can even do things like:

"#{n} #{n == 1 ? 'error prevents' : 'errors prevent'} the saving of the record."

which tends to get very little help from the Inflector.

-Rob

Rob Biedenharn          
[email protected]     http://AgileConsultingLLC.com/
[email protected]               http://GaslightSoftware.com/

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to