<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,13 @@
 *Edge*
 
+* Add Inflection rules for String#humanize. #535 [dcmanges]
+
+  ActiveSupport::Inflector.inflections do |inflect|
+    inflect.human(/_cnt$/i, '\1_count')
+  end
+
+  'jargon_cnt'.humanize # =&gt; 'Jargon count'
+
 * TimeWithZone: when crossing DST boundary, treat Durations of days, months or years as variable-length, and all other values as absolute length. A time + 24.hours will advance exactly 24 hours, but a time + 1.day will advance 23-25 hours, depending on the day. Ensure consistent behavior across all advancing methods [Geoff Buesing]
 
 * Added TimeZone #=~, to support matching zones by regex in time_zone_select. #195 [Ernie Miller]</diff>
      <filename>activesupport/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -30,10 +30,10 @@ module ActiveSupport
     class Inflections
       include Singleton
 
-      attr_reader :plurals, :singulars, :uncountables
+      attr_reader :plurals, :singulars, :uncountables, :humans
 
       def initialize
-        @plurals, @singulars, @uncountables = [], [], []
+        @plurals, @singulars, @uncountables, @humans = [], [], [], []
       end
 
       # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
@@ -76,9 +76,20 @@ module ActiveSupport
         (@uncountables &lt;&lt; words).flatten!
       end
 
+      # Specifies a humanized form of a string by a regular expression rule or by a string mapping.
+      # When using a regular expression based replacement, the normal humanize formatting is called after the replacement.
+      # When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name')
+      #
+      # Examples:
+      #   human /_cnt$/i, '\1_count'
+      #   human &quot;legacy_col_person_name&quot;, &quot;Name&quot;
+      def human(rule, replacement)
+        @humans.insert(0, [rule, replacement])
+      end
+
       # Clears the loaded inflections within a given scope (default is &lt;tt&gt;:all&lt;/tt&gt;).
       # Give the scope as a symbol of the inflection type, the options are: &lt;tt&gt;:plurals&lt;/tt&gt;,
-      # &lt;tt&gt;:singulars&lt;/tt&gt;, &lt;tt&gt;:uncountables&lt;/tt&gt;.
+      # &lt;tt&gt;:singulars&lt;/tt&gt;, &lt;tt&gt;:uncountables&lt;/tt&gt;, &lt;tt&gt;:humans&lt;/tt&gt;.
       #
       # Examples:
       #   clear :all
@@ -209,7 +220,10 @@ module ActiveSupport
     #   &quot;employee_salary&quot; # =&gt; &quot;Employee salary&quot;
     #   &quot;author_id&quot;       # =&gt; &quot;Author&quot;
     def humanize(lower_case_and_underscored_word)
-      lower_case_and_underscored_word.to_s.gsub(/_id$/, &quot;&quot;).gsub(/_/, &quot; &quot;).capitalize
+      result = lower_case_and_underscored_word.to_s.dup
+
+      inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
+      result.gsub(/_id$/, &quot;&quot;).gsub(/_/, &quot; &quot;).capitalize
     end
 
     # Removes the module part from the expression in the string.</diff>
      <filename>activesupport/lib/active_support/inflector.rb</filename>
    </modified>
    <modified>
      <diff>@@ -110,6 +110,23 @@ class InflectorTest &lt; Test::Unit::TestCase
     end
   end
 
+  def test_humanize_by_rule
+    ActiveSupport::Inflector.inflections do |inflect|
+      inflect.human(/_cnt$/i, '\1_count')
+      inflect.human(/^prefx_/i, '\1')
+    end
+    assert_equal(&quot;Jargon count&quot;, ActiveSupport::Inflector.humanize(&quot;jargon_cnt&quot;))
+    assert_equal(&quot;Request&quot;, ActiveSupport::Inflector.humanize(&quot;prefx_request&quot;))
+  end
+
+  def test_humanize_by_string
+    ActiveSupport::Inflector.inflections do |inflect|
+      inflect.human(&quot;col_rpted_bugs&quot;, &quot;Reported bugs&quot;)
+    end
+    assert_equal(&quot;Reported bugs&quot;, ActiveSupport::Inflector.humanize(&quot;col_rpted_bugs&quot;))
+    assert_equal(&quot;Col rpted bugs&quot;, ActiveSupport::Inflector.humanize(&quot;COL_rpted_bugs&quot;))
+  end
+
   def test_constantize
     assert_nothing_raised { assert_equal Ace::Base::Case, ActiveSupport::Inflector.constantize(&quot;Ace::Base::Case&quot;) }
     assert_nothing_raised { assert_equal Ace::Base::Case, ActiveSupport::Inflector.constantize(&quot;::Ace::Base::Case&quot;) }
@@ -148,7 +165,7 @@ class InflectorTest &lt; Test::Unit::TestCase
     end
   end
 
-  %w{plurals singulars uncountables}.each do |inflection_type|
+  %w{plurals singulars uncountables humans}.each do |inflection_type|
     class_eval &quot;
       def test_clear_#{inflection_type}
         cached_values = ActiveSupport::Inflector.inflections.#{inflection_type}
@@ -160,25 +177,29 @@ class InflectorTest &lt; Test::Unit::TestCase
   end
 
   def test_clear_all
-    cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables
+    cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables, ActiveSupport::Inflector.inflections.humans
     ActiveSupport::Inflector.inflections.clear :all
     assert ActiveSupport::Inflector.inflections.plurals.empty?
     assert ActiveSupport::Inflector.inflections.singulars.empty?
     assert ActiveSupport::Inflector.inflections.uncountables.empty?
+    assert ActiveSupport::Inflector.inflections.humans.empty?
     ActiveSupport::Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
     ActiveSupport::Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
     ActiveSupport::Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
+    ActiveSupport::Inflector.inflections.instance_variable_set :@humans, cached_values[3]
   end
 
   def test_clear_with_default
-    cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables
+    cached_values = ActiveSupport::Inflector.inflections.plurals, ActiveSupport::Inflector.inflections.singulars, ActiveSupport::Inflector.inflections.uncountables, ActiveSupport::Inflector.inflections.humans
     ActiveSupport::Inflector.inflections.clear
     assert ActiveSupport::Inflector.inflections.plurals.empty?
     assert ActiveSupport::Inflector.inflections.singulars.empty?
     assert ActiveSupport::Inflector.inflections.uncountables.empty?
+    assert ActiveSupport::Inflector.inflections.humans.empty?
     ActiveSupport::Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
     ActiveSupport::Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
     ActiveSupport::Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
+    ActiveSupport::Inflector.inflections.instance_variable_set :@humans, cached_values[3]
   end
 
   Irregularities.each do |irregularity|
@@ -217,7 +238,7 @@ class InflectorTest &lt; Test::Unit::TestCase
     end
   end
 
-  { :singulars =&gt; :singular, :plurals =&gt; :plural, :uncountables =&gt; :uncountable }.each do |scope, method|
+  { :singulars =&gt; :singular, :plurals =&gt; :plural, :uncountables =&gt; :uncountable, :humans =&gt; :human }.each do |scope, method|
     ActiveSupport::Inflector.inflections do |inflect|
       define_method(&quot;test_clear_inflections_with_#{scope}&quot;) do
         # save the inflections</diff>
      <filename>activesupport/test/inflector_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3a95ee73cfbcfeada3b053c5b0fb7b5125ef12c7</id>
    </parent>
  </parents>
  <author>
    <name>Pratik Naik</name>
    <login>lifo</login>
    <email>pratiknaik@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/4f75840d72b96fff34d65b59480da7d6c7494120</url>
  <id>4f75840d72b96fff34d65b59480da7d6c7494120</id>
  <committed-date>2008-07-02T05:25:36-07:00</committed-date>
  <authored-date>2008-07-02T05:25:17-07:00</authored-date>
  <message>Add Inflection rules for String#humanize. [#535 state:resolved] [dcmanges]

Signed-off-by: Pratik Naik &lt;pratiknaik@gmail.com&gt;</message>
  <tree>cd13f9cf0359811c262e47737e704b059312ee05</tree>
  <committer>
    <name>Pratik Naik</name>
    <login>lifo</login>
    <email>pratiknaik@gmail.com</email>
  </committer>
</commit>
