开发者

How do I specify custom wording in a will_paginate view helper?

I'm using will_paginate 2.3.25 with Rails 2.3.11.

I'd like my page_entries_info view helper to say "Displa开发者_如何学Pythonying all n [my own custom wording]s" instead of auto-generating the item name based on the model.

What is the syntax to make it do that?


Set up your translation yaml file to include what you want to call that model when it is being paginated.

After reading this documentation: https://github.com/mislav/will_paginate/wiki/I18n

en:
  will_paginate:
    models:
      line_item:
        zero:  line items
        one:   line item
        few:   line items
        other: line items

Or for a "just this once solution" you can use page_entries_info

From the RDoc:

page_entries_info(collection, options = {})

Renders a helpful message with numbers of displayed vs. total entries. You can use this as a blueprint for your own, similar helpers.

  <%= page_entries_info @posts %>
  #-> Displaying posts 6 - 10 of 26 in total

By default, the message will use the humanized class name of objects in collection: for instance, "project types" for ProjectType models. Override this with the :entry_name parameter:

  <%= page_entries_info @posts, :entry_name => 'item' %>
  #-> Displaying items 6 - 10 of 26 in total


Use the :entry_name parameter.

= page_entries_info @posts, :entry_name => 'item'
#-> Displaying items 6 - 10 of 26 in total
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜