class R18n::RailsPlural

Converter between R18n and Rails I18n plural keys.

Public Class Methods

from_r18n(key) click to toggle source

Convert R18n plural key to Rails I18n.

# File lib/r18n-rails-api/rails_plural.rb, line 34
def self.from_r18n(key)
  { 0 => :zero, 1 => :one, 2 => :few, 'n' => :other }[key]
end
rails?(key) click to toggle source

Check, that `key` is Rails plural key.

# File lib/r18n-rails-api/rails_plural.rb, line 24
def self.rails?(key)
  %i[zero one few many other].include? key
end
to_r18n(key) click to toggle source

Convert Rails I18n plural key to R18n.

# File lib/r18n-rails-api/rails_plural.rb, line 29
def self.to_r18n(key)
  { zero: 0, one: 1, few: 2, many: 'n', other: 'n' }[key]
end