Module: Wallaby::Locale

Defined in:
lib/utils/wallaby/locale.rb

Overview

Locale related

Class Method Summary collapse

Class Method Details

.t(key, options = {}) ⇒ String

Extend translation just for Wallaby so that translation can be prefixed with ‘wallaby.`

Parameters:

  • key (String, Symbol, Array)
  • options (Hash) (defaults to: {})

    the rest of the arguments

Returns:

  • (String)

    translation



12
13
14
15
16
17
18
19
# File 'lib/utils/wallaby/locale.rb', line 12

def t(key, options = {})
  translator = options.delete(:translator) || I18n.method(:t)
  return translator.call(key, options) unless key.is_a?(String) || key.is_a?(Symbol)

  new_key, new_defaults = normalize key, options.delete(:default)

  translator.call(new_key, default: new_defaults, **options)
end