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

- (Object) key (readonly)

Returns the value of attribute key



54
55
56
# File 'lib/i18n/exceptions.rb', line 54

def key
  @key
end

- (Object) locale (readonly)

Returns the value of attribute locale



54
55
56
# File 'lib/i18n/exceptions.rb', line 54

def locale
  @locale
end

- (Object) options (readonly)

Returns the value of attribute options



54
55
56
# File 'lib/i18n/exceptions.rb', line 54

def options
  @options
end

Instance Method Details

- (Object) html_message



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

def html_message
  key  = CGI.escapeHTML titleize(keys.last)
  path = CGI.escapeHTML keys.join('.')
  %(<span class="translation_missing" title="translation missing: #{path}">#{key}</span>)
end

- (Object) initialize(locale, key, options = nil)



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

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

- (Object) keys



67
68
69
70
71
# File 'lib/i18n/exceptions.rb', line 67

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

- (Object) message Also known as: to_s



73
74
75
# File 'lib/i18n/exceptions.rb', line 73

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

- (Object) to_exception



78
79
80
# File 'lib/i18n/exceptions.rb', line 78

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