module I18n::Backend::Metadata - i18n-0.6.11 Documentation

# module I18n::Backend::Metadata

### Public Instance Methods

included(base) click to toggle source

    # File lib/i18n/backend/metadata.rb, line 21
    def included(base)
      Object.class_eval do
        def translation_metadata
          @translation_metadata ||= {}
        end

        def translation_metadata=(translation_metadata)
          @translation_metadata = translation_metadata
        end
      end unless Object.method_defined?(:translation_metadata)
    end

interpolate(locale, entry, values = {}) click to toggle source
Calls superclass method

    # File lib/i18n/backend/metadata.rb, line 46
    def interpolate(locale, entry, values = {})
      metadata = entry.translation_metadata.merge(:original => entry)
      with_metadata(metadata) { super }
    end

pluralize(locale, entry, count) click to toggle source
Calls superclass method

    # File lib/i18n/backend/metadata.rb, line 51
    def pluralize(locale, entry, count)
      with_metadata(:count => count) { super }
    end

translate(locale, key, options = {}) click to toggle source
Calls superclass method

    # File lib/i18n/backend/metadata.rb, line 34
    def translate(locale, key, options = {})
      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

translation_metadata() click to toggle source

    # File lib/i18n/backend/metadata.rb, line 23
    def translation_metadata
      @translation_metadata ||= {}
    end

translation_metadata=(translation_metadata) click to toggle source

    # File lib/i18n/backend/metadata.rb, line 27
    def translation_metadata=(translation_metadata)
      @translation_metadata = translation_metadata
    end

### Protected Instance Methods

with_metadata(metadata) { || ... } click to toggle source

    # File lib/i18n/backend/metadata.rb, line 57
    def with_metadata(metadata, &block)
      result = yield
      result.translation_metadata = result.translation_metadata.merge(metadata) if result
      result
    end