Skip to content

Commit

Permalink
i18n: fix model_name fallback for Rails
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Aug 5, 2011
1 parent 52056ee commit fbb6f6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/will_paginate/view_helpers.rb
Expand Up @@ -114,15 +114,17 @@ def page_entries_info(collection, options = {})
end

model_count = collection.total_pages > 1 ? 5 : collection.size
model_name = will_paginate_translate "models.#{model_key}", :count => model_count do |_, opts|
defaults = ["models.#{model_key}"]
defaults << Proc.new { |_, opts|
if model.respond_to? :model_name
model.model_name.human(:count => opts[:count])
else
name = model_key.to_s.tr('_', ' ')
raise "can't pluralize model name: #{model.inspect}" unless name.respond_to? :pluralize
opts[:count] == 1 ? name : name.pluralize
end
end
}
model_name = will_paginate_translate defaults, :count => model_count

if collection.total_pages < 2
i18n_key = :"page_entries_info.single_page#{html_key}"
Expand Down

0 comments on commit fbb6f6b

Please sign in to comment.