Question

I'm using kaminari for pagination in a rails project and it's working great. I've generate the views and locale files for it too.

One issue I'm having however is using the name of the collection thats being paginated in the pagination text.

For example on blog posts I want the next pages link to say "Older blog posts" or on a comments pagination the text should say "Older comments".

The text for this label is coming from the locale file with this line in the kaminari views:

<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote, :class => "older" %>

Spesicfiall the raw(t 'views.pagination.next') which is coming from the en.yml locale file. So how do I display different text per collection in this label.

Thanks!

Was it helpful?

Solution

You can try the following

# locale
en:
  views:
    pagination:
      next: "Newer %{title}"

Then on the view, you can use

t('views.pagination.next', title: @comments.first.class.name.underscore.humanize.pluralize)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top