module I18n::MissingTranslation::Base
Constants
- PERMITTED_KEYS
Attributes
key[R]
locale[R]
options[R]
Public Class Methods
new(locale, key, options = EMPTY_HASH)
click to toggle source
# File lib/i18n/exceptions.rb, line 53 def initialize(locale, key, options = EMPTY_HASH) @key, @locale, @options = key, locale, options.slice(*PERMITTED_KEYS) options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) } end
Public Instance Methods
keys()
click to toggle source
# File lib/i18n/exceptions.rb, line 58 def keys @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys| keys << 'no key' if keys.size < 2 end end
message()
click to toggle source
# File lib/i18n/exceptions.rb, line 64 def message if (default = options[:default]).is_a?(Array) && default.any? other_options = ([key, *default]).map { |k| normalized_option(k).prepend('- ') }.join("\n") "Translation missing. Options considered were:\n#{other_options}" else "Translation missing: #{keys.join('.')}" end end
Also aliased as: to_s
normalized_option(key)
click to toggle source
# File lib/i18n/exceptions.rb, line 73 def normalized_option(key) I18n.normalize_keys(locale, key, options[:scope]).join('.') end
to_exception()
click to toggle source
# File lib/i18n/exceptions.rb, line 79 def to_exception MissingTranslationData.new(locale, key, options) end