<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 5 way(s) to pluralize</title>
	<atom:link href="http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/feed/" rel="self" type="application/rss+xml" />
	<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 15:43:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: George</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-86494</link>
		<dc:creator>George</dc:creator>
		<pubDate>Wed, 07 Dec 2011 04:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-86494</guid>
		<description>Bit of inline PHP, which also pluralizes in the case of 0 (your search returned 0 results).
&lt;p&gt;your search returned &lt;?php echo count($search_results);?&gt; result&lt;?php count($search_results)==0&#124;&#124;count($search_results)&gt;1?&#039;s&#039;:&#039;&#039;;?&gt;</description>
		<content:encoded><![CDATA[<p>Bit of inline PHP, which also pluralizes in the case of 0 (your search returned 0 results).<br />
&lt;p&gt;your search returned &lt;?php echo count($search_results);?&gt; result&lt;?php count($search_results)==0||count($search_results)&gt;1?&#039;s&#039;:&#039;&#039;;?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-86493</link>
		<dc:creator>George</dc:creator>
		<pubDate>Wed, 07 Dec 2011 04:41:53 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-86493</guid>
		<description>Bit of inline PHP, which also pluralizes in the case of 0 (your search returned 0 results).

your search returned  result1?&#039;s&#039;:&#039;&#039;;?&gt;</description>
		<content:encoded><![CDATA[<p>Bit of inline PHP, which also pluralizes in the case of 0 (your search returned 0 results).</p>
<p>your search returned  result1?&#8217;s':&#8221;;?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sohail Amir</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-86421</link>
		<dc:creator>Sohail Amir</dc:creator>
		<pubDate>Sun, 10 Jul 2011 02:06:46 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-86421</guid>
		<description>Thanks for this, exactly what I was looking for and the code works perfectly!</description>
		<content:encoded><![CDATA[<p>Thanks for this, exactly what I was looking for and the code works perfectly!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shaun</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-86375</link>
		<dc:creator>Shaun</dc:creator>
		<pubDate>Wed, 13 Apr 2011 06:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-86375</guid>
		<description>Love Rails ;)

pluralize(1, &#039;person&#039;)
# =&gt; 1 person

pluralize(2, &#039;person&#039;)
# =&gt; 2 people

pluralize(3, &#039;person&#039;, &#039;users&#039;)
# =&gt; 3 users

pluralize(0, &#039;person&#039;)
# =&gt; 0 people</description>
		<content:encoded><![CDATA[<p>Love Rails <img src='http://boulter.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>pluralize(1, &#8216;person&#8217;)<br />
# =&gt; 1 person</p>
<p>pluralize(2, &#8216;person&#8217;)<br />
# =&gt; 2 people</p>
<p>pluralize(3, &#8216;person&#8217;, &#8216;users&#8217;)<br />
# =&gt; 3 users</p>
<p>pluralize(0, &#8216;person&#8217;)<br />
# =&gt; 0 people</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-85784</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 17 Nov 2009 15:34:30 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-85784</guid>
		<description># File actionpack/lib/action_view/helpers/text_helper.rb, line 183

def pluralize(count, singular, plural = nil)
  &quot;#{count &#124;&#124; 0} &quot; + ((count == 1 &#124;&#124; count == &#039;1&#039;) ? singular : (plural &#124;&#124; singular.pluralize))
end

Welcome to the Rails community. :)</description>
		<content:encoded><![CDATA[<p># File actionpack/lib/action_view/helpers/text_helper.rb, line 183</p>
<p>def pluralize(count, singular, plural = nil)<br />
  &#8220;#{count || 0} &#8221; + ((count == 1 || count == &#8217;1&#8242;) ? singular : (plural || singular.pluralize))<br />
end</p>
<p>Welcome to the Rails community. <img src='http://boulter.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-14598</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 05 Apr 2007 21:17:18 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-14598</guid>
		<description>The same as yours, in one line, but yes a little less understandable:

function pluralize($count, $singular, $plural = false)
{
  return ($count == 1 ? $singular : ($plural ? $plural : $singular . &#039;s&#039;)) ;
}</description>
		<content:encoded><![CDATA[<p>The same as yours, in one line, but yes a little less understandable:</p>
<p>function pluralize($count, $singular, $plural = false)<br />
{<br />
  return ($count == 1 ? $singular : ($plural ? $plural : $singular . &#8216;s&#8217;)) ;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Osman</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-13997</link>
		<dc:creator>Paul Osman</dc:creator>
		<pubDate>Sun, 18 Mar 2007 02:33:28 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-13997</guid>
		<description>Shamelessly lifted from the rails inflector class: 

http://paulosman.com/node/23</description>
		<content:encoded><![CDATA[<p>Shamelessly lifted from the rails inflector class: </p>
<p><a href="http://paulosman.com/node/23" rel="nofollow">http://paulosman.com/node/23</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jody</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-10092</link>
		<dc:creator>Jody</dc:creator>
		<pubDate>Mon, 14 Aug 2006 19:53:52 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-10092</guid>
		<description>I wrote this function today after not finding one in the PHP manual.  I tried a few test cases but I&#039;m no grammar expert so I may have missed some conditions.  It&#039;s really hard to tell how to pluralize words ending in &#039;o&#039;, so a lot of those might not work well.  Also, for the words in the $irregulars array, the comparison is case sensitive, so you may have to add your own formatting in there.  It&#039;s not perfect, but it&#039;s not bad for 10 mintues.   If you see any more irregulars I am missing please post them in response.  

function pluralize($string)
	{
		$irregulars = array(&#039;man&#039; =&gt; &#039;men&#039;, &#039;woman&#039; =&gt; &#039;women&#039;, &#039;fungus&#039; =&gt; &#039;fungi&#039;, &#039;thief&#039; =&gt; &#039;thieves&#039;, &#039;species&#039; =&gt; &#039;species&#039;,
									 &#039;medium&#039; =&gt; &#039;media&#039;,&#039;person&#039; =&gt; &#039;people&#039;, &#039;echo&#039; =&gt; &#039;echoes&#039;, &#039;hero&#039; =&gt; &#039;heroes&#039;, &#039;potato&#039; =&gt; &#039;potatoes&#039;, 
									 &#039;veto&#039; =&gt; &#039;vetoes&#039;, &#039;auto&#039; =&gt; &#039;autos&#039;, &#039;memo&#039; =&gt; &#039;memos&#039;, &#039;pimento&#039; =&gt; &#039;pimentos&#039;, &#039;pro&#039; =&gt; &#039;pros&#039;);

		$es = array(&#039;s&#039;, &#039;z&#039;, &#039;ch&#039;, &#039;sh&#039;, &#039;x&#039;);
		
		$last_letter = $string{strlen($string) - 1};
		
		if(array_key_exists($string, $irregulars))
		{
			return $irregulars[$string];
		} 
		else if($last_letter == &#039;y&#039;) 
		{
			if($string{strlen($string) - 2} == &#039;e&#039;)
					return substr($string, 0, strlen($string) - 2) . &#039;ies&#039;; 
				else
					return substr($string, 0, strlen($string) - 1) . &#039;ies&#039;; 
		}
		else if(in_array(substr($string,0,-2),$es) &#124;&#124; in_array($last_letter, $es))
		{
			return $string . &#039;es&#039;;
		}
		else
		{
			return $string . &#039;s&#039;;
		}
	}</description>
		<content:encoded><![CDATA[<p>I wrote this function today after not finding one in the PHP manual.  I tried a few test cases but I&#8217;m no grammar expert so I may have missed some conditions.  It&#8217;s really hard to tell how to pluralize words ending in &#8216;o&#8217;, so a lot of those might not work well.  Also, for the words in the $irregulars array, the comparison is case sensitive, so you may have to add your own formatting in there.  It&#8217;s not perfect, but it&#8217;s not bad for 10 mintues.   If you see any more irregulars I am missing please post them in response.  </p>
<p>function pluralize($string)<br />
	{<br />
		$irregulars = array(&#8216;man&#8217; =&gt; &#8216;men&#8217;, &#8216;woman&#8217; =&gt; &#8216;women&#8217;, &#8216;fungus&#8217; =&gt; &#8216;fungi&#8217;, &#8216;thief&#8217; =&gt; &#8216;thieves&#8217;, &#8216;species&#8217; =&gt; &#8216;species&#8217;,<br />
									 &#8216;medium&#8217; =&gt; &#8216;media&#8217;,'person&#8217; =&gt; &#8216;people&#8217;, &#8216;echo&#8217; =&gt; &#8216;echoes&#8217;, &#8216;hero&#8217; =&gt; &#8216;heroes&#8217;, &#8216;potato&#8217; =&gt; &#8216;potatoes&#8217;,<br />
									 &#8216;veto&#8217; =&gt; &#8216;vetoes&#8217;, &#8216;auto&#8217; =&gt; &#8216;autos&#8217;, &#8216;memo&#8217; =&gt; &#8216;memos&#8217;, &#8216;pimento&#8217; =&gt; &#8216;pimentos&#8217;, &#8216;pro&#8217; =&gt; &#8216;pros&#8217;);</p>
<p>		$es = array(&#8216;s&#8217;, &#8216;z&#8217;, &#8216;ch&#8217;, &#8216;sh&#8217;, &#8216;x&#8217;);</p>
<p>		$last_letter = $string{strlen($string) &#8211; 1};</p>
<p>		if(array_key_exists($string, $irregulars))<br />
		{<br />
			return $irregulars[$string];<br />
		}<br />
		else if($last_letter == &#8216;y&#8217;)<br />
		{<br />
			if($string{strlen($string) &#8211; 2} == &#8216;e&#8217;)<br />
					return substr($string, 0, strlen($string) &#8211; 2) . &#8216;ies&#8217;;<br />
				else<br />
					return substr($string, 0, strlen($string) &#8211; 1) . &#8216;ies&#8217;;<br />
		}<br />
		else if(in_array(substr($string,0,-2),$es) || in_array($last_letter, $es))<br />
		{<br />
			return $string . &#8216;es&#8217;;<br />
		}<br />
		else<br />
		{<br />
			return $string . &#8216;s&#8217;;<br />
		}<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Galen</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-4120</link>
		<dc:creator>Galen</dc:creator>
		<pubDate>Thu, 22 Dec 2005 20:41:23 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-4120</guid>
		<description>I take it there is no easy (reliable) way in PHP to:
a &#124; Make singular words plural
b &#124; Make plural words singular

For example, simply removing the S&#039;s isn&#039;t a good option since a word like grass would become gras. Adding an S is not ideal as fish becomes fishs... I guess if there is no vowel on the end, &quot;es&quot; could be added. Is there a function out there that anyone knows of that handles the various possibilities? If so, I would be very grateful if someone could email the link to me.

Many thanks.</description>
		<content:encoded><![CDATA[<p>I take it there is no easy (reliable) way in PHP to:<br />
a | Make singular words plural<br />
b | Make plural words singular</p>
<p>For example, simply removing the S&#8217;s isn&#8217;t a good option since a word like grass would become gras. Adding an S is not ideal as fish becomes fishs&#8230; I guess if there is no vowel on the end, &#8220;es&#8221; could be added. Is there a function out there that anyone knows of that handles the various possibilities? If so, I would be very grateful if someone could email the link to me.</p>
<p>Many thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PHP-Scripts Blog</title>
		<link>http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/comment-page-1/#comment-4071</link>
		<dc:creator>PHP-Scripts Blog</dc:creator>
		<pubDate>Sat, 10 Dec 2005 17:39:48 +0000</pubDate>
		<guid isPermaLink="false">http://boulter.com/blog/2005/04/22/5-ways-to-pluralize/#comment-4071</guid>
		<description>&lt;strong&gt;How to pluralize using PHP&lt;/strong&gt;

	This is one of those technical nitpick things. Check out the screenshot below of the new Yahoo Answers and see if you can spot the error. 
	
	The title of this thread kind of gives it away. Note the &#8220;1 Answers&#8221; should actually read &#8220;...</description>
		<content:encoded><![CDATA[<p><strong>How to pluralize using PHP</strong></p>
<p>	This is one of those technical nitpick things. Check out the screenshot below of the new Yahoo Answers and see if you can spot the error. </p>
<p>	The title of this thread kind of gives it away. Note the &#8220;1 Answers&#8221; should actually read &#8220;&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

