Included Modules

I18n::Backend::Chain::Implementation

Attributes

backends[RW]

Public Class Methods

new(*backends) click to toggle source
# File lib/i18n/backend/chain.rb, line 23
def initialize(*backends)
  self.backends = backends
end

Public Instance Methods

available_locales() click to toggle source
# File lib/i18n/backend/chain.rb, line 35
def available_locales
  backends.map { |backend| backend.available_locales }.flatten.uniq
end
localize(locale, object, format = :default, options = {}) click to toggle source
# File lib/i18n/backend/chain.rb, line 61
def localize(locale, object, format = :default, options = {})
  backends.each do |backend|
    begin
      result = backend.localize(locale, object, format, options) and return result
    rescue MissingTranslationData
    end
  end
  raise(I18n::MissingTranslationData.new(locale, format, options))
end
reload!() click to toggle source
# File lib/i18n/backend/chain.rb, line 27
def reload!
  backends.each { |backend| backend.reload! }
end
store_translations(locale, data, options = {}) click to toggle source
# File lib/i18n/backend/chain.rb, line 31
def store_translations(locale, data, options = {})
  backends.first.store_translations(locale, data, options = {})
end
translate(locale, key, default_options = {}) click to toggle source
# File lib/i18n/backend/chain.rb, line 39
def translate(locale, key, default_options = {})
  namespace = nil
  options = default_options.except(:default)

  backends.each do |backend|
    begin
      options = default_options if backend == backends.last
      translation = backend.translate(locale, key, options)
      if namespace_lookup?(translation, options)
        namespace ||= {}
        namespace.merge!(translation)
      elsif !translation.nil?
        return translation
      end
    rescue MissingTranslationData
    end
  end

  return namespace if namespace
  raise(I18n::MissingTranslationData.new(locale, key, options))
end

Protected Instance Methods

namespace_lookup?(result, options) click to toggle source
# File lib/i18n/backend/chain.rb, line 72
def namespace_lookup?(result, options)
  result.is_a?(Hash) && !options.has_key?(:count)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.