@@ -84,19 +84,31 @@ def build_download_format_links(formats = [:csv, :xml, :json])
8484
8585 # modified from will_paginate
8686 def page_entries_info ( options = { } )
87- entry_name = options [ :entry_name ] ||
88- ( collection . empty? ? 'entry' : collection . first . class . name . underscore . sub ( '_' , ' ' ) )
87+ if options [ :entry_name ]
88+ entry_name = options [ :entry_name ]
89+ elsif collection . empty?
90+ entry_name = I18n . translate ( "active_admin.pagination.entry" , :count => 1 , :default => 'entry' )
91+ entries_name = I18n . translate ( "active_admin.pagination.entry" , :count => 2 , :default => 'entries' )
92+ else
93+ begin
94+ entry_name = I18n . translate! ( "activerecord.models.#{ collection . first . class . name . i18n_key } " , :count => 1 )
95+ entries_name = I18n . translate! ( "activerecord.models.#{ collection . first . class . name . i18n_key } " , :count => collection . size )
96+ rescue I18n ::MissingTranslationData
97+ entry_name = collection . first . class . name . underscore . sub ( '_' , ' ' )
98+ end
99+ end
100+ entries_name = entry_name . pluralize unless entries_name
89101
90102 if collection . num_pages < 2
91103 case collection . size
92- when 0 ; I18n . t ( 'active_admin.pagination.empty' , :model => entry_name . pluralize )
104+ when 0 ; I18n . t ( 'active_admin.pagination.empty' , :model => entries_name )
93105 when 1 ; I18n . t ( 'active_admin.pagination.one' , :model => entry_name )
94- else ; I18n . t ( 'active_admin.pagination.one_page' , :model => entry_name . pluralize , :n => collection . size )
106+ else ; I18n . t ( 'active_admin.pagination.one_page' , :model => entries_name , :n => collection . size )
95107 end
96108 else
97109 offset = collection . current_page * active_admin_application . default_per_page
98110 total = collection . total_count
99- I18n . t ( 'active_admin.pagination.multiple' , :model => entry_name . pluralize , :from => ( offset - active_admin_application . default_per_page + 1 ) , :to => offset > total ? total : offset , :total => total )
111+ I18n . t ( 'active_admin.pagination.multiple' , :model => entries_name , :from => ( offset - active_admin_application . default_per_page + 1 ) , :to => offset > total ? total : offset , :total => total )
100112 end
101113 end
102114
0 commit comments