module I18n::Backend::Metadata
def included(base)
def included(base) Object.class_eval do def translation_metadata unless self.frozen? @translation_metadata ||= {} else {} end end def translation_metadata=(translation_metadata) @translation_metadata = translation_metadata unless self.frozen? end end unless Object.method_defined?(:translation_metadata) end
def interpolate(locale, entry, values = EMPTY_HASH)
def interpolate(locale, entry, values = EMPTY_HASH) metadata = entry.translation_metadata.merge(:original => entry) with_metadata(metadata) { super } end
def pluralize(locale, entry, count)
def pluralize(locale, entry, count) with_metadata(:count => count) { super } end
def translate(locale, key, options = EMPTY_HASH)
def translate(locale, key, options = EMPTY_HASH) metadata = { :locale => locale, :key => key, :scope => options[:scope], :default => options[:default], :separator => options[:separator], :values => options.reject { |name, _value| RESERVED_KEYS.include?(name) } } with_metadata(metadata) { super } end
def translation_metadata
def translation_metadata unless self.frozen? @translation_metadata ||= {} else {} end end
def translation_metadata=(translation_metadata)
def translation_metadata=(translation_metadata) @translation_metadata = translation_metadata unless self.frozen? end
def with_metadata(metadata, &block)
def with_metadata(metadata, &block) result = yield result.translation_metadata = result.translation_metadata.merge(metadata) if result result end