engines/adva_cms/vendor/plugins/globalize2/lib/globalize/backend/chain.rb
# For defaults:
# Never pass any default option to the backends but instead implement our own default
# mechanism (e.g. symbols as defaults would need to be passed to the whole chain to
# be translated).
#
# For namespace lookup: 
# Only return if the result is not a hash OR count is not present, otherwise merge them.
# So in effect the count variable would control whether we have a namespace lookup or a 
# pluralization going on.
#
# Exceptions:
# Make sure that we catch MissingTranslationData exceptions and raise
# one in the end when no translation was found at all.
#
# For bulk translation:
# If the key is an array we need to call #translate for each of the
# keys and collect the results.
For defaults:
Never pass any default option to the backends but instead implement our own default
mechanism .

For namespace lookup:
Only return if the result is not a hash OR count is not present, otherwise merge them.
So in effect the count variable would control whether we have a namespace lookup or a
pluralization going on.

Make sure that we catch MissingTranslationData exceptions and raise
one in the end when no translation was found at all.

For bulk translation:
If the key is an array we need to call #translate for each of the
keys and collect the results.
For defaults : Never pass any default option to the backends but instead implement our own default mechanism . For namespace lookup : Only return if the result is not a hash OR count is not present otherwise merge them . So in effect the count variable would control whether we have a namespace lookup or a pluralization going on . Make sure that we catch MissingTranslationData exceptions and raise one in the end when no translation was found at all . For bulk translation : If the key is an array we need to call #translate for each of the keys and collect the results .
def translate(locale, key, options = {})
        raise I18n::InvalidLocale.new(locale) if locale.nil?
        return key.map{|k| translate locale, k, options } if key.is_a? Array
        default = options.delete(:default)
        result = backends.inject({}) do |namespace, backend|
          begin
            translation = backend.translate(locale.to_sym, key, options) 
            if namespace_lookup?(translation, options)
              namespace.merge! translation
            elsif translation
              return translation 
            end
          rescue I18n::MissingTranslationData
          end
        end
        result || default(locale, default, options) || raise(I18n::MissingTranslationData.new(locale, key, options))
      end
def translate ( locale , key , options = { } ) raise I18n :: InvalidLocale . new ( locale ) if locale . nil? return key . map { | k | translate locale , k , options } if key . is_a? Array default = options . delete ( :default ) result = backends . inject ( { } ) do | namespace , backend | begin translation = backend . translate ( locale . to_sym , key , options ) if namespace_lookup? ( translation , options ) namespace . merge! translation elsif translation return translation end rescue I18n :: MissingTranslationData end end result || default ( locale , default , options ) || raise ( I18n :: MissingTranslationData . new ( locale , key , options ) ) end
For defaults:
Never pass any default option to the backends but instead implement our own default
mechanism (e.g.
For defaults : Never pass any default option to the backends but instead implement our own default mechanism ( e . g .
locale
key
options