Class: Telegram::BotManager::Localizer
- Inherits:
-
Object
- Object
- Telegram::BotManager::Localizer
- Defined in:
- lib/telegram/bot_manager/localizer.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
Returns the value of attribute locale.
Instance Method Summary collapse
-
#initialize(locale) ⇒ Localizer
constructor
A new instance of Localizer.
- #pick(path, params = {}) ⇒ Object
- #samples(path, params = {}) ⇒ Object
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
#locale ⇒ Object
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 |