72453

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 "Displaying 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?

Answer1:

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

Answer2:

Use the :entry_name parameter.

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

Recommend

  • in solr is there an way to fetch all results from a query something like start=0&rows=* or rows=
  • Is it possible to query Google Cloud Storage similar to using `ls` command in terminal?
  • How to loop through all rows in DataTables jQuery?
  • Endless pagination loads entire page contents on scroll
  • Uploading entity with parent using bulkloader
  • why is cobra not reading my config file
  • Copying different structs to byte arrays
  • Why is YAML.load returning the wrong numeric value?
  • Moving Object in ScrollViewer
  • Android WebView does not display web page correctly
  • How to write an install script for ubuntu
  • Use OAuth2 for authentication + compatibility with google.appengine.api.users service
  • how do you read the ramda docs?
  • Save and retrieve an image file in LibGDX
  • What does the “?” mean in the following statement
  • eC (Ecere) how to not worry about private data fields of a class
  • What's the name of this finding square root algorithm?
  • Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE
  • Installed module is empty
  • Installing Apache MyFaces 2 on WildFly 8.2.0
  • jQuery .attr() and value
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Adding custom controls to a full screen movie
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to disable jQuery.jplayer autoplay?
  • Buffer size for converting unsigned long to string
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How to set the response of a form post action to a iframe source?
  • Hits per day in Google Big Query
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • coudnt use logback because of log4j
  • Change div Background jquery
  • How does Linux kernel interrupt the application?
  • Qt: Run a script BEFORE make
  • How to get Windows thread pool to call class member function?
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory
  • Why do underscore prefixed variables exist?