Skip to content
Browse files

Using ActiveSupport::CoreExtensions::String::Inflections.pluralize (a…

…nd singularize) when current locale is English
  • Loading branch information...
1 parent 32930d1 commit a83ce80998b73d53dec6e82051570574b969168e Paul Engel committed Oct 4, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/rich/pluralization/inflector.rb
View
8 lib/rich/pluralization/inflector.rb
@@ -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 ? [] : {}))

0 comments on commit a83ce80

Please sign in to comment.
Something went wrong with that request. Please try again.