module ActionView::Helpers::TextHelper
def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)
pluralize(2, 'Person', locale: :de)
# => "0 people"
pluralize(0, 'person')
# => "3 users"
pluralize(3, 'person', plural: 'users')
# => "2 people"
pluralize(2, 'person')
# => "1 person"
pluralize(1, 'person')
See ActiveSupport::Inflector.pluralize
(you must define your own inflection rules for languages other than English).
The word will be pluralized using rules defined for the locale
which defaults to +I18n.locale+.
it will use the Inflector to determine the plural form for the given locale,
+plural+ is supplied, it will use that when count is > 1, otherwise
Attempts to pluralize the +singular+ word unless +count+ is 1. If
def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale) word = if count == 1 || count.to_s.match?(/^1(\.0+)?$/) singular else plural || singular.pluralize(locale) end "#{count || 0} #{word}" end