irregular(singular, plural)
  public
  
    
    
Specifies a new irregular
that applies to both pluralization and singularization at the same time.
This can only be used for strings, not regular expressions. You simply pass
the irregular
in singular and
plural
form.
irregular 'octopus', 'octopi'
irregular 'person', 'people'
   
  
    Show source    
    
      
      def irregular(singular, plural)
        @uncountables.delete(singular)
        @uncountables.delete(plural)
        s0 = singular[0]
        srest = singular[1..-1]
        p0 = plural[0]
        prest = plural[1..-1]
        if s0.upcase == p0.upcase
          plural(/(#{s0})#{srest}$/, '\1' + prest)
          plural(/(#{p0})#{prest}$/, '\1' + prest)
          singular(/(#{s0})#{srest}$/, '\1' + srest)
          singular(/(#{p0})#{prest}$/, '\1' + srest)
        else
          plural(/#{s0.upcase}(?i)#{srest}$/,   p0.upcase   + prest)
          plural(/#{s0.downcase}(?i)#{srest}$/, p0.downcase + prest)
          plural(/#{p0.upcase}(?i)#{prest}$/,   p0.upcase   + prest)
          plural(/#{p0.downcase}(?i)#{prest}$/, p0.downcase + prest)
          singular(/#{s0.upcase}(?i)#{srest}$/,   s0.upcase   + srest)
          singular(/#{s0.downcase}(?i)#{srest}$/, s0.downcase + srest)
          singular(/#{p0.upcase}(?i)#{prest}$/,   s0.upcase   + srest)
          singular(/#{p0.downcase}(?i)#{prest}$/, s0.downcase + srest)
        end
      end