def apply_inflections(word, rules, locale = :en)
        result = word.to_s.dup

        if word.empty? || inflections(locale).uncountables.uncountable?(result)
          result
        else
          rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) }
          result
        end
      end
def apply_inflections(word, rules, locale = :en)
        result = word.to_s.dup

        if word.empty? || inflections(locale).uncountables.uncountable?(result)
          result
        else
          rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) }
          result
        end
      end
Applies inflection rules for +singularize+ and +pluralize+.

 If passed an optional +locale+ parameter, the uncountables will be
 found for that locale.

  apply_inflections('post', inflections.plurals, :en)    # => "posts"
  apply_inflections('posts', inflections.singulars, :en) # => "post"