Skip to content

I18n implemented and russian support added. #109

wants to merge 2 commits into from

5 participants

MrHant commented Mar 12, 2011


Implementation of I18n.

  • custom locale files in config/locales gem folder
  • custom pluralization for different locales ('ru' pluralization should be different from 'en' one)

This commit shouldn't change current behavior of En locale and I think is pretty clear.

Hopefully it will suite your needs.

Best Regards,
Artyom S.


Incorrect "previous" translation: should be "← Пред."

Упс. Согласен.

np :)


Incorrect "next" translation: should be "След. →"

komba commented May 26, 2011

It doesn't working.

      previous: "← Пред."
      next: 'След. →'


= will_paginate @stats
= I18n.t('will_paginate.pagination_options.previous')

← Previous 1 2 Next →
← Пред.

I18n 0.5.0, rails 3.0.7


MrHant, I really want this feature but when I was reading this part of the code I thought "it will be difficult to support new languages if we embed language specific conditions in the code" like this.
I propose a change, where we provide all context information which can be partially or fully used (via the interpolations variable) depending on the current specific language.
Something like:

interpolations = {
  :entry_name => entry_name,
  :plural_name => plural_name,
  :size => collection.size,
  :begin => collection.offset + 1,
  :end => collection.offset + collection.length,
  :total => collection.total_entries,
  :b => b,
  :eb => eb,
  :sp => sp

translation_key, default = 
  if collection.total_pages < 2
    case collection.size
    when 0; [ 'will_paginate.page_entries.nothing', "No #{plural_name} found" ]
    when 1; [ '', "Displaying #{b}1#{eb} #{entry_name}" ]
    else; [ 'will_paginate.page_entries.other', "Displaying #{b}all #{collection.size}#{eb} #{plural_name}" ]
    [ 'will_paginate.page_entries.range', %{Displaying #{plural_name} #{b}%d#{sp}-#{sp}%d#{eb} of #{b}%d#{eb} in total} % [
      collection.offset + 1, collection.offset + collection.length, collection.total_entries ] ]

I18n.t translation_key, interpolations.merge(:default => default)

What do you think about it?

@mislav mislav added a commit that referenced this pull request Jul 28, 2011
@mislav have no fear, i18n is here!
:previous_label, :next_label, page gap text and the `page_entries_info`
method output can now all be translated by overriding values seen in
"lib/will_paginate/locale/en.yml" from your own application locale files.

closes #99, #10, #109
mislav commented Jul 28, 2011

Finally, i18n is in will_paginate for Rails 3. See for values you can override.

I'm going to try to backport this to will_paginate 2.3.x for people running Rails 2.

I didn't pull this pull request because it creates a dependency to I18n while with my change I only rely on I18n if it's present, but also include defaults in the codebase.

@mislav mislav closed this Jul 28, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.