Exception: I18n::MissingTranslationData
- Inherits:
-
ArgumentError
- Object
- ArgumentError
- ArgumentError
- I18n::MissingTranslationData
- Defined in:
- lib/i18n/exceptions.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #html_message ⇒ Object
-
#initialize(locale, key, opts = nil) ⇒ MissingTranslationData
constructor
A new instance of MissingTranslationData.
- #keys ⇒ Object
Constructor Details
#initialize(locale, key, opts = nil) ⇒ MissingTranslationData
Returns a new instance of MissingTranslationData.
39 40 41 42 43 |
# File 'lib/i18n/exceptions.rb', line 39 def initialize(locale, key, opts = nil) @key, @locale, @options = key, locale, opts.dup || {} .each { |k, v| [k] = v.inspect if v.is_a?(Proc) } super "translation missing: #{keys.join('.')}" end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
37 38 39 |
# File 'lib/i18n/exceptions.rb', line 37 def key @key end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
37 38 39 |
# File 'lib/i18n/exceptions.rb', line 37 def locale @locale end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
37 38 39 |
# File 'lib/i18n/exceptions.rb', line 37 def @options end |
Instance Method Details
#html_message ⇒ Object
45 46 47 48 |
# File 'lib/i18n/exceptions.rb', line 45 def key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize } %(<span class="translation_missing" title="translation missing: #{keys.join('.')}">#{key}</span>) end |
#keys ⇒ Object
50 51 52 53 54 |
# File 'lib/i18n/exceptions.rb', line 50 def keys @keys ||= I18n.normalize_keys(locale, key, [:scope]).tap do |keys| keys << 'no key' if keys.size < 2 end end |