mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Adding i18n to page_entries_info fixes #208
This commit is contained in:
parent
6df7869cbd
commit
8fedb4f77d
2 changed files with 15 additions and 10 deletions
|
@ -8,3 +8,12 @@ en:
|
|||
previous: "‹ Prev"
|
||||
next: "Next ›"
|
||||
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} - %{last}</b> of <b>%{total}</b> in total"
|
||||
|
|
|
@ -94,20 +94,16 @@ module Kaminari
|
|||
entry_name = entry_name.underscore.sub('_', ' ')
|
||||
end
|
||||
entry_name = options[:entry_name] unless options[:entry_name].nil?
|
||||
entry_name = entry_name.pluralize unless collection.total_count == 1
|
||||
output = ""
|
||||
if collection.num_pages < 2
|
||||
output = case collection.total_count
|
||||
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
|
||||
output = t("helpers.page_entries_info.one_page.display_entries", { :count => collection.total_count, :entry_name => entry_name })
|
||||
else
|
||||
offset = (collection.current_page - 1) * collection.limit_value
|
||||
output = %{Displaying #{entry_name.pluralize} <b>%d - %d</b> of <b>%d</b> in total} % [
|
||||
offset + 1,
|
||||
offset + collection.current_page_count,
|
||||
collection.total_count
|
||||
]
|
||||
output = t("helpers.page_entries_info.more_pages.display_entries", { :entry_name => entry_name,
|
||||
:first => offset + 1,
|
||||
:last => offset + collection.current_page_count,
|
||||
:total => collection.total_count })
|
||||
end
|
||||
output.html_safe
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue