Module: Anoubis::Core::Locales

Defined in:
app/models/anoubis/core/locales.rb

Overview

Defines all available locales.

Constant Summary collapse

LIST =

List of all possible locales.

{
  ru: { id: 1, name: 'Russian' },
  en: { id: 2, name: 'English' },
  kz: { id: 3, name: 'Kazakh' }
}.freeze

Class Method Summary collapse

Class Method Details

.enumsSymbol

Converts list of locales into enum attribute

Returns:

  • (Symbol)

    return symbols array for all locales.



23
24
25
# File 'app/models/anoubis/core/locales.rb', line 23

def enums
  LIST.reduce({}) { |res, v| res.merge("#{v.first}": v.last[:id]) }
end

.name(key) ⇒ String

Returns the title of chosen locale

Parameters:

  • key (String)

    identificator of locale (‘ru’, ‘en’, etc.)

Returns:

  • (String)

    english title of locale



16
17
18
# File 'app/models/anoubis/core/locales.rb', line 16

def name(key)
  LIST[key.to_sym][:name]
end