app/helpers/admin/i18n_helper.rb
# Tries to find the most applicable translation for a particular key, based on model name. This is similar to the
# way Rails handles fallbacks for validation messages and the like, just for our own specific ends =)
#
# === Parameters
#
# [object] the model instance or class the localisation is for
# [key] the I18n key to get
# [scope] an array of one or more I18n key stems to use
# [defaults] any defaults to be passed to I18n#translate
Tries to find the most applicable translation for a particular key, based on model name. This is similar to the
way Rails handles fallbacks for validation messages and the like, just for our own specific ends =)

Parameters

[object] the model instance or class the localisation is for
[key] the I18n key to get
[scope] an array of one or more I18n key stems to use
[defaults] any defaults to be passed to I18n#translate
Tries to find the most applicable translation for a particular key based on model name . This is similar to the way Rails handles fallbacks for validation messages and the like just for our own specific ends = ) Parameters [ object ] the model instance or class the localisation is for [ key ] the I18n key to get [ scope ] an array of one or more I18n key stems to use [ defaults ] any defaults to be passed to I18n#translate
def fallthru_t( object, key, scope, defaults )
      i18n_object = i18n_object_for( object )
      scope = scope.map{ |k| [ :"admin.#{k}.models.#{i18n_object.i18n_key}.#{key}", :"admin.#{k}.#{key}" ]}.flatten
      options = defaults.merge( create_defaults_for( i18n_object, object ))
      options = { default: scope }.merge( options.except( :default ))
      t( scope.shift, options )
    end
def fallthru_t ( object , key , scope , defaults ) i18n_object = i18n_object_for ( object ) scope = scope . map { | k | [ :" admin. #{ k } .models. #{ i18n_object . i18n_key } . #{ key } " , :" admin. #{ k } . #{ key } " ] } . flatten options = defaults . merge ( create_defaults_for ( i18n_object , object ) ) options = { default : scope } . merge ( options . except ( :default ) ) t ( scope . shift , options ) end
Tries to find the most applicable translation for a particular key, based on model name.
Tries to find the most applicable translation for a particular key based on model name .
# normalise our inbound object # translate our scope into model-specific keys # set some general defaults for substitution # add our fallbacks # translate
object
key
scope
defaults