Adding i18n to page_entries_info fixes #208

This commit is contained in:
Paulo Henrique Lopes Ribeiro 2012-02-21 20:10:34 -02:00
parent 6df7869cbd
commit 8fedb4f77d
2 changed files with 15 additions and 10 deletions

View File

@ -8,3 +8,12 @@ en:
previous: "‹ Prev" previous: "‹ Prev"
next: "Next ›" next: "Next ›"
truncate: "..." truncate: "..."
helpers:
page_entries_info:
one_page:
display_entries:
zero: "No %{entry_name} found"
one: "Displaying <b>1</b> %{entry_name}"
other: "Displaying <b>all %{count}</b> %{entry_name}"
more_pages:
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"

View File

@ -94,20 +94,16 @@ module Kaminari
entry_name = entry_name.underscore.sub('_', ' ') entry_name = entry_name.underscore.sub('_', ' ')
end end
entry_name = options[:entry_name] unless options[:entry_name].nil? entry_name = options[:entry_name] unless options[:entry_name].nil?
entry_name = entry_name.pluralize unless collection.total_count == 1
output = "" output = ""
if collection.num_pages < 2 if collection.num_pages < 2
output = case collection.total_count output = t("helpers.page_entries_info.one_page.display_entries", { :count => collection.total_count, :entry_name => entry_name })
when 0; "No #{entry_name.pluralize} found"
when 1; "Displaying <b>1</b> #{entry_name}"
else; "Displaying <b>all #{collection.total_count}</b> #{entry_name.pluralize}"
end
else else
offset = (collection.current_page - 1) * collection.limit_value offset = (collection.current_page - 1) * collection.limit_value
output = %{Displaying #{entry_name.pluralize} <b>%d&nbsp;-&nbsp;%d</b> of <b>%d</b> in total} % [ output = t("helpers.page_entries_info.more_pages.display_entries", { :entry_name => entry_name,
offset + 1, :first => offset + 1,
offset + collection.current_page_count, :last => offset + collection.current_page_count,
collection.total_count :total => collection.total_count })
]
end end
output.html_safe output.html_safe
end end