module Telegram::Bot::UpdatesController::Translation
Provides helpers similar to AbstractController::Translation but by default uses `action_name_i18n_key` in lazy translation keys which strips `!` from action names by default. This makes translating strings for commands more convenient.
To disable this behaviour use `alias_method :action_name_i18n_key, :action_name`.
Public Instance Methods
action_name_i18n_key()
click to toggle source
Strips trailing `!` from action_name.
# File lib/telegram/bot/updates_controller/translation.rb, line 36 def action_name_i18n_key action_name.chomp('!') end
localize(*args)
click to toggle source
# File lib/telegram/bot/updates_controller/translation.rb, line 40 def localize(*args) I18n.localize(*args) end
Also aliased as: l
translate(key, **options)
click to toggle source
See toplevel description.
# File lib/telegram/bot/updates_controller/translation.rb, line 23 def translate(key, **options) if key.to_s.start_with?('.') path = controller_path.tr('/', '.') defaults = [:"#{path}#{key}"] defaults << options[:default] if options[:default] options[:default] = defaults.flatten key = "#{path}.#{action_name_i18n_key}#{key}" end I18n.translate(key, **options) end
Also aliased as: t