Included Modules

Class Index [+]

Quicksearch

I18n::Backend::Chain::Implementation

Attributes

backends[RW]

Public Class Methods

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

Public Instance Methods

available_locales() click to toggle source
    # File lib/i18n/backend/chain.rb, line 35
35:         def available_locales
36:           backends.map { |backend| backend.available_locales }.flatten.uniq
37:         end
localize(locale, object, format = :default, options = {}) click to toggle source
    # File lib/i18n/backend/chain.rb, line 60
60:         def localize(locale, object, format = :default, options = {})
61:           backends.each do |backend|
62:             catch(:exception) do
63:               result = backend.localize(locale, object, format, options) and return result
64:             end
65:           end
66:           throw(:exception, I18n::MissingTranslation.new(locale, format, options))
67:         end
reload!() click to toggle source
    # File lib/i18n/backend/chain.rb, line 27
27:         def reload!
28:           backends.each { |backend| backend.reload! }
29:         end
store_translations(locale, data, options = {}) click to toggle source
    # File lib/i18n/backend/chain.rb, line 31
31:         def store_translations(locale, data, options = {})
32:           backends.first.store_translations(locale, data, options)
33:         end
translate(locale, key, default_options = {}) click to toggle source
    # File lib/i18n/backend/chain.rb, line 39
39:         def translate(locale, key, default_options = {})
40:           namespace = nil
41:           options = default_options.except(:default)
42: 
43:           backends.each do |backend|
44:             catch(:exception) do
45:               options = default_options if backend == backends.last
46:               translation = backend.translate(locale, key, options)
47:               if namespace_lookup?(translation, options)
48:                 namespace ||= {}
49:                 namespace.merge!(translation)
50:               elsif !translation.nil?
51:                 return translation
52:               end
53:             end
54:           end
55: 
56:           return namespace if namespace
57:           throw(:exception, I18n::MissingTranslation.new(locale, key, options))
58:         end

Protected Instance Methods

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.