Permalink
Browse files

Revert commit 7e25a. It broke pluralization.

Category.model_name.human(:count => 3)
  # => "Category" # instead of "Categories"
  • Loading branch information...
1 parent c3a1ffa commit 2e3a18726874133ef8d58e32f64bfac0d0e92395 @pcreux pcreux committed Aug 15, 2011
Showing with 1 addition and 5 deletions.
  1. +1 −5 lib/active_admin/resource/naming.rb
@@ -28,11 +28,7 @@ def resource_name
# Returns the plural version of this resource
def plural_resource_name
- @plural_resource_name ||= if @options[:as] || !resource.respond_to?(:model_name)
- resource_name.pluralize
- else
- resource.model_name.human(:count => 3)
- end
+ @plural_resource_name ||= resource_name.pluralize
end
end

4 comments on commit 2e3a187

libo commented on 2e3a187 Aug 16, 2011

Ok it works fine if you have a pluralization rule

I18n.locale = :it
ruby-1.8.7-p302 > Student.model_name.human(:count => 3)
=> "Studenti" 
ruby-1.8.7-p302 > Student.model_name.human(:count => 1)
 => "Studente"

As soon as I have time I write a spec and try to fix it...

libo replied Aug 16, 2011

this should make it

  # Returns the plural version of this resource
  def plural_resource_name
    @plural_resource_name ||= if @options[:as] || !resource.respond_to?(:model_name)
      resource_name.pluralize
    else
      # Check if we have a translation available otherwise pluralize
      begin
        I18n.translate!("activerecord.models.#{resource.model_name.downcase}")
        resource.model_name.human(:count => 3)
      rescue I18n::MissingTranslationData
        resource_name.pluralize
      end
    end
  end
libo replied Aug 16, 2011

I'll write a spec asap and make a pull request

libo replied Aug 16, 2011

Here is the patch

libo@adf23d7

Please sign in to comment.