Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatted pluralize

I have a case where I need to use pluralize to properly spell something. However, I need to render the html like so:

<span>1</span> thing

or,

<span>3</span> things

I could write a helper method, but I'm just making sure there isn't something in the box to do this.

like image 834
Tim Sullivan Avatar asked Feb 03 '09 16:02

Tim Sullivan


People also ask

What is the plural of formatting?

Noun. formatting (countable and uncountable, plural formattings) The visual style of a document, including fonts, borders, etc.

How do you pluralize a letter?

Key Point: Pluralize a single letter by adding apostrophe-s. To form the plural of a single letter, italicize the letter and add an apostrophe followed by the unitalicized letter s. Recommended: We called tech support because the printer wasn't printing uppercase B's or lowercase p's.

How do you determine if a word is plural?

The easiest way to tell if a noun is a singular noun or a plural noun is to look at how much of something it is referring to. If it is only referring to one person or thing, it is a singular noun. If it is referring to more than one person or thing, it is a plural noun.


1 Answers

This uses the Rails class TextHelper which uses Inflector to do the pluralization if needed.

def pluralize_with_html(count, word)
  "<span>#{count}</span> #{TextHelper.pluralize(count, word)}"
end
like image 76
Lolindrath Avatar answered Oct 22 '22 17:10

Lolindrath