Class: R18n::RailsPlural
- Inherits:
-
Object
- Object
- R18n::RailsPlural
- Defined in:
- lib/r18n-rails-api/rails_plural.rb
Overview
Converter between R18n and Rails I18n plural keys.
Class Method Summary collapse
-
.from_r18n(key) ⇒ Object
Convert R18n plural key to Rails I18n.
-
.rails?(key) ⇒ Boolean
Check, that ‘key` is Rails plural key.
-
.to_r18n(key) ⇒ Object
Convert Rails I18n plural key to R18n.
Class Method Details
.from_r18n(key) ⇒ Object
Convert R18n plural key to Rails I18n.
34 35 36 |
# 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) ⇒ Boolean
Check, that ‘key` is Rails plural key.
24 25 26 |
# 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) ⇒ Object
Convert Rails I18n plural key to R18n.
29 30 31 |
# 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 |