Entry fallback translation #309

wants to merge 1 commit into


None yet

7 participants


Without this isn't possible to translate the default "entry name"


The code looks better indeed, but I'm afraid this change will cause "translation missing" for the users of existing versions.
I think using I18n is a good idea, but maybe we still need to fallback to hardcoded 'entry' String for now.

zzak commented Aug 7, 2013

We will merge this in next major release. Thank you!

It would be nice to have tests for this as well.

yuki24 commented Mar 22, 2014

@amatsuda @zzak We are now working on the next major version, which is 1.0.0. Maybe now is a good time to merge this request?

@yuki24 yuki24 added this to the 1.0.0 milestone Apr 1, 2014
@yuki24 yuki24 self-assigned this May 16, 2014

+1 Need this as well

@Linuus Linuus commented on the diff Jun 10, 2014
else # AR
- collection.model_name.human.downcase
+ entry_name = collection.model_name.human.downcase
Linuus Jun 10, 2014 Contributor

When using AR, isn't it better to do something like:

entry_name = collection.model_name.human(count: collection.total_count).downcase

And not use .pluralize? This way it uses the plural/singular translations for AR and does not mess up when the language is not english.

When I have a model called Article it is translated to Swedish like this in my local file:

        one: Artikel
        other: Artiklar

Kaminari picks the Artikel translation and pluralizes it to Artikels which is wrong.

If we use:

entry_name = collection.model_name.human(count: collection.total_count).downcase

It will instead pick the correct plural version of the word.

We can even specify to use pluralization if there is no translation, like this:

entry_name = collection.model_name.human(count: collection.total_count, default: c.model_name.human.pluralize).downcase

What do you think about that?

yuki24 Jun 10, 2014 Member

Sounds good to me. Maybe we can do this in Kaminari::ActiveRecordRelationMethods?

Linuus Jun 10, 2014 Contributor

That seems appropriate I guess. If we have access to the collection/count there to pass to the #human method.

Also, we should use collection.count and not collection.total_count. Total count is the number entries on all pages, right?

yuki24 Jun 10, 2014 Member

Yes, we can simply do this:

def entry_name
  model_name.human(count: total_count).downcase
  # or...
  # model_name.human(count: total_count, default: model_name.human.pluralize).downcase
Linuus Jun 10, 2014 Contributor

@yuki24 But we shouldn't use total_count, right? We want to base the pluralization on the number of entries being displayed and not the number of entries on all pages.

yuki24 Jun 10, 2014 Member

You are right, we should use just #count, #size or #length.

yuki24 commented Jun 10, 2014

@thibaultponcelet could you rebase this branch?


Why are we down-casing the entry name? In some languages (like German) the first letter of a noun is a capital letter.

yuki24 commented Feb 19, 2015

@openscript we were not just aware of it. But simply removing downcase will introduce an issue in other languages like English. Try to come up with a solution that works in both cases.


Yes, I'm thinking about that right now. Stay tuned!


I've sent a pull request.

@yuki24 yuki24 closed this in #694 Oct 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment