Internationalization
Pagy handles string translation and pluralization using its own efficient i18n implementation.
Apps using only English language, are supported out of the box without any I18n Setup!
All Pagy strings are stored in dictionary files within its locales. These files adopt the same structure as the standard locale files for the i18n gem, allowing you to use them seamlessly with both engines.
Recommended: ~18x faster and ~10x lighter
It works seamlessly even if the rest of your app works with the i18n gem.
Set the Pagy::I18n.locale for each request. For example:
before_action { Pagy::I18n.locale = params[:locale] }
Notice: The default Pagy::I18n.locale is 'en'.
Slower
Switch the translation to the i18n gem. Pagy will provide only its dictionaries...
Pagy.translate_with_the_slower_i18n_gem!
# See https://ddnexus.github.io/pagy/resources/i18n
en:
pagy:
p11n: 'OneOther'
aria_label:
nav:
one: "Page"
other: "Pages"
previous: "Previous"
next: "Next"
previous: "<"
next: ">"
gap: "…"
item_name:
one: "item"
other: "items"
info_tag:
no_count: "Page %{page} of %{pages}"
no_items: "No %{item_name} found"
single_page: "Displaying %{count} %{item_name}"
multiple_pages: "Displaying %{item_name} %{from}-%{to} of %{count} in total"
input_nav_js: "Page %{page_input} of %{pages}"
limit_tag_js: "Show %{limit_input} %{item_name} per page"
IMPORTANT
If you use Pagy::I18n, name your custom dictionary as <locale>.yml.
Place your custom dictionaries in a directory and add its path to the I18n pathnames.
# Example for Rails:
Pagy::I18n.pathnames << Rails.root.join('config/locales/pagy')
Feel free to ask for further help via Pagy Support.
•1  Locate the file of your locale in the list of pluralizations
•2  Check the pluralization used in it.
•3  Confirm that Pagy has the same pluralization in the P18n directory.
easy  Create a new Feature Request asking for the addition of the pluralization for your locale.
best  Create a new module for the pluralization (by adapting the same pluralization from the corresponding rails-i18n file) and include tests for it
•1  Pick a dictionary in the lib/locales.
•2
 Set the p11n entry to the right pluralization module name in the P18n directory.
•3
 Provide the necessary plurals for aria_label.nav and item_name.
E.g., with EastSlavic rule, provide the plurals for one, few, many, and other. With Other provide only the other value, etc.
Localization is needed only by the calendar with non en locales localization.