Class: Telegram::BotManager::Localizer

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram/bot_manager/localizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale) ⇒ Localizer

Returns a new instance of Localizer.



9
10
11
12
# File 'lib/telegram/bot_manager/localizer.rb', line 9

def initialize(locale)
  @locale = locale
  ::I18n.locale = locale
end

Instance Attribute Details

#localeObject

Returns the value of attribute locale.



7
8
9
# File 'lib/telegram/bot_manager/localizer.rb', line 7

def locale
  @locale
end

Instance Method Details

#pick(path, params = {}) ⇒ Object



18
19
20
# File 'lib/telegram/bot_manager/localizer.rb', line 18

def pick(path, params={})
  samples(path, params).sample
end

#samples(path, params = {}) ⇒ Object



14
15
16
# File 'lib/telegram/bot_manager/localizer.rb', line 14

def samples(path, params={})
  ::I18n.t(path, params.merge(default_params))
end