fixes kaminari inability to pluralize spanish names
This commit is contained in:
@@ -8,3 +8,50 @@ Kaminari.configure do |config|
|
||||
# config.page_method_name = :page
|
||||
# config.param_name = :page
|
||||
end
|
||||
|
||||
|
||||
# Overrides for making Kaminari handle i18n pluralization correctly
|
||||
#
|
||||
# Remove everything below once https://github.com/amatsuda/kaminari/pull/694 is
|
||||
# merged in Kaminari and we have updated
|
||||
module Kaminari
|
||||
|
||||
module ActionViewExtension
|
||||
def page_entries_info(collection, options = {})
|
||||
entry_name = if options[:entry_name]
|
||||
options[:entry_name].pluralize(collection.size)
|
||||
else
|
||||
collection.entry_name(:count => collection.size).downcase
|
||||
end
|
||||
|
||||
if collection.total_pages < 2
|
||||
t('helpers.page_entries_info.one_page.display_entries', entry_name: entry_name, count: collection.total_count)
|
||||
else
|
||||
first = collection.offset_value + 1
|
||||
last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
|
||||
t('helpers.page_entries_info.more_pages.display_entries', entry_name: entry_name, first: first, last: last, total: collection.total_count)
|
||||
end.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
module ActiveRecordRelationMethods
|
||||
def entry_name(options = {})
|
||||
model_name.human(options.reverse_merge(default: model_name.human.pluralize(options[:count])))
|
||||
end
|
||||
end
|
||||
|
||||
module MongoidCriteriaMethods
|
||||
def entry_name(options = {})
|
||||
model_name.human(options.reverse_merge(default: model_name.human.pluralize(options[:count])))
|
||||
end
|
||||
end
|
||||
|
||||
class PaginatableArray < Array
|
||||
ENTRY = 'entry'.freeze
|
||||
|
||||
def entry_name(options = {})
|
||||
I18n.t('helpers.page_entries_info.entry', options.reverse_merge(default: ENTRY.pluralize(options[:count])))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,12 +1,33 @@
|
||||
es:
|
||||
activerecord:
|
||||
models:
|
||||
comment: Comentario
|
||||
debate: Debate
|
||||
tag: Tema
|
||||
user: Usuario
|
||||
vote: Voto
|
||||
organization: Organización
|
||||
comment:
|
||||
one: Comentario
|
||||
other: Comentarios
|
||||
debate:
|
||||
one: Debate
|
||||
other: Debates
|
||||
tag:
|
||||
one: Tema
|
||||
other: Temas
|
||||
user:
|
||||
one: Usuario
|
||||
other: Usuarios
|
||||
moderator:
|
||||
one: Moderador
|
||||
other: Moderadores
|
||||
administrator:
|
||||
one: Administrador
|
||||
other: Administradores
|
||||
vote:
|
||||
one: Voto
|
||||
other: Voto
|
||||
organization:
|
||||
one: Organización
|
||||
other: Organizaciones
|
||||
proposal:
|
||||
one: Propuesta ciudadana
|
||||
other: Propuestas ciudadanas
|
||||
attributes:
|
||||
comment:
|
||||
body: Comentario
|
||||
@@ -16,7 +37,7 @@ es:
|
||||
description: Opinión
|
||||
terms_of_service: Términos de servicio
|
||||
title: Título
|
||||
propuesta:
|
||||
proposal:
|
||||
author: Autor
|
||||
title: Título
|
||||
question: Pregunta
|
||||
|
||||
@@ -8,10 +8,14 @@ en:
|
||||
truncate: "…"
|
||||
helpers:
|
||||
page_entries_info:
|
||||
entry:
|
||||
zero: "entries"
|
||||
one: "entry"
|
||||
other: "entries"
|
||||
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"
|
||||
display_entries: "Displaying %{entry_name} <b>%{first} - %{last}</b> of <b>%{total}</b> in total"
|
||||
|
||||
@@ -8,10 +8,14 @@ es:
|
||||
truncate: "…"
|
||||
helpers:
|
||||
page_entries_info:
|
||||
entry:
|
||||
zero: "entradas"
|
||||
one: "entrada"
|
||||
other: "entradas"
|
||||
one_page:
|
||||
display_entries:
|
||||
zero: "No se han encontrado %{entry_name}"
|
||||
one: "Encontrado <b>1</b> %{entry_name}"
|
||||
other: "Encontrados <b> %{count}</b> %{entry_name}"
|
||||
one: "Hay <b>1</b> %{entry_name}"
|
||||
other: "Hay <b> %{count}</b> %{entry_name}"
|
||||
more_pages:
|
||||
display_entries: "Se muestran <b> del %{first} al %{last}</b> de un total de <b>%{total}</b> %{entry_name}"
|
||||
display_entries: "Mostrando <b>%{first} - %{last}</b> de un total de <b>%{total}</b> %{entry_name}"
|
||||
|
||||
Reference in New Issue
Block a user