pluralization_with_count
🔢 Pluralization with count​
Rails I18n supports pluralization rules based on the count
option. Define one
and other
keys in your locale file and pass the count
to t
for automatic singular/plural selection.
<!-- app/views/notifications/index.html.erb -->
<p><%= t('notifications.messages', count: @messages.size) %></p>
# config/locales/en.yml
en:
notifications:
messages:
one: "You have %{count} new message"
other: "You have %{count} new messages"