I like to localize the "previous" and "next" links in will_paginate, how can I do that? Did anyone find a nice workaround?
Asked
Active
Viewed 3,751 times
2 Answers
18
will_paginate
accepts a Hash of options, including options to customize the previous/next labels.
<%= will_paginate @collection, :previous_label => t("previous"), :next_label => t("next") %>

Simone Carletti
- 173,507
- 49
- 363
- 364
-
I did that but I get en, Precedente 1 2 3 EN, PROSSIMO what's with the "en"? – akmur Feb 09 '12 at 09:43
-
I just passing by to say tank you. It yas just what I needed. – Wagner Braga Apr 04 '20 at 21:58
9
In case someone else found the thread..., there is an another solution now.
https://github.com/mislav/will_paginate/wiki/I18n
The following is extracted from the above link.
As of will_paginate v2.3.16 and v3.0, some output of will_paginate view helper and the complete output of page_entries_info helper can be translated by means of the i18n library.
In Rails, this usually means adding your translations in YAML or ruby format in the "config/locale/" directory.
Translation keys and default values for the will_paginate helper can be seen here:
en:
will_paginate:
previous_label: "Previous"
next_label: "Next"
page_gap: "…"

William L.
- 139
- 1
- 6
-
I'm curious as to why this was downvoted; it seems like an excellent solution to me. (I'm not in a position to test it right now though so I can't say for sure.) – Ajedi32 Feb 21 '14 at 14:19
-
A nice solution, explained in the gem wiki on github, but seems like something's wrong with it for me. Tried to add a translation in another locale, but it still shows the same output. – Almaron May 26 '14 at 14:43
-
Upgrading from will_paginate 3.0.3 to 3.1.0 seems to have caused it to stop reading the translations in the app. The will_paginate locale file is now the last item in `config.i18n.load_paths` so it overrides the locale in the file. – jwadsack Jan 18 '16 at 23:37