Jan 17
The current will_paginate plugin doesn’t support localization. Adding the following code into the application_helper will enable i18n for will_paginate.
include WillPaginate::ViewHelpers
def will_paginate_with_i18n(collection, options = {})
will_paginate_without_i18n(collection, options.merge(:previous_label => I18n.t(:previous), :next_label => I18n.t(:next)))
end
alias_method_chain :will_paginate, :i18n
And add ‘next’ and ‘previous’ attribute in the locales file.
for example zh.yml under RAILS_ROOT/config/locales
zh: previous: '前一页' next: '下一页'
January 23rd, 2009 at 6:00 am
Very nice!
I would add a default option to I18n.translate in order to keep backward compatibility:
will_paginate_without_i18n(collection, options.merge(:previous_label => I18n.t(’previous’, :default=>’Previous’), :next_label => I18n.t(’next’, :default => ‘Next’)))
February 6th, 2009 at 4:27 am
Nice!. Thanks!.
February 7th, 2009 at 8:46 am
The key :previous_label doesn’t work for me (using the will_paginate gem instead of the plugin). Had to change it to :prev_label.
April 2nd, 2009 at 4:05 am
Nice work!
May 9th, 2009 at 6:48 pm
Thx, works fine for me 2.
September 12th, 2009 at 5:09 am
Works for me, and I am using the gem.
config.gem ‘mislav-will_paginate’, :version => ‘~> 2.3.8′, :lib => ‘will_paginate’, :source => ‘http://gems.github.com’
Thanks
f.
December 18th, 2009 at 11:14 pm
Thanks Lawrence, I implemented this successfully for iLearnWords (http://www.ilearnwords.com/), an audio-based language learning site!