Module: I18n::MissingTranslation::Base

Included in:
I18n::MissingTranslation, I18n::MissingTranslationData
Defined in:
lib/i18n/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key



43
44
45
# File 'lib/i18n/exceptions.rb', line 43

def key
  @key
end

#localeObject (readonly)

Returns the value of attribute locale



43
44
45
# File 'lib/i18n/exceptions.rb', line 43

def locale
  @locale
end

#optionsObject (readonly)

Returns the value of attribute options



43
44
45
# File 'lib/i18n/exceptions.rb', line 43

def options
  @options
end

Instance Method Details

#initialize(locale, key, options = nil) ⇒ Object



45
46
47
48
49
# File 'lib/i18n/exceptions.rb', line 45

def initialize(locale, key, options = nil)
  options = options ? options.dup : {}
  @key, @locale, @options = key, locale, options
  options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) }
end

#keysObject



51
52
53
54
55
# File 'lib/i18n/exceptions.rb', line 51

def keys
  @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys|
    keys << 'no key' if keys.size < 2
  end
end

#messageObject Also known as: to_s



57
58
59
# File 'lib/i18n/exceptions.rb', line 57

def message
  "translation missing: #{keys.join('.')}"
end

#to_exceptionObject



62
63
64
# File 'lib/i18n/exceptions.rb', line 62

def to_exception
  MissingTranslationData.new(locale, key, options)
end