Skip to content

Commit

Permalink
Using ActiveSupport::CoreExtensions::String::Inflections.pluralize (a…
Browse files Browse the repository at this point in the history
…nd singularize) when current locale is English
  • Loading branch information
Paul Engel authored and Paul Engel committed Oct 4, 2010
1 parent 32930d1 commit a83ce80
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rich/pluralization/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ def inflections(locale = nil)
end

def singularize(word)
inflect :singulars, word
in_english? ? word.singularize : inflect(:singulars, word)
end

def pluralize(word, count = nil)
count == 1 ? singularize(word) : inflect(:plurals, word)
count == 1 ? singularize(word) : (in_english? ? word.pluralize : inflect(:plurals, word))
end

private

def in_english?
I18n.locale.to_s == "en"
end

[:singulars, :plurals, :irregulars, :uncountables].each do |type|
define_method type do
(Inflections.instance.send(type)[I18n.locale] || (type == :uncountables ? [] : {}))
Expand Down

0 comments on commit a83ce80

Please sign in to comment.