Sha256: 7053069db7992b9d703a4f3e9ee4e757e5429ef55e7b25a92145b9b33d3db997
Contents?: true
Size: 1.22 KB
Versions: 10
Compression:
Stored size: 1.22 KB
Contents
module CopycopterClient # Helper methods for Copycopter # @deprecated use +I81n#translate+ instead. module Helper # Returns copy for the given key in the current locale. # @param key [String] the key you want copy for # @param default [String, Hash] an optional default value, used if this key is missing # @option default [String] :default the default text def copy_for(key, default=nil) default = if default.respond_to?(:to_hash) default[:default] else default end key = scope_copycopter_key_by_partial(key) warn("WARNING: #s is deprecated; use t(#{key.inspect}, :default => #{default.inspect}) instead.") I18n.translate(key, { :default => default }) end alias_method :s, :copy_for private def scope_copycopter_key_by_partial(key) if respond_to?(:scope_key_by_partial, true) scope_key_by_partial(key) elsif key.to_s[0].chr == "." if respond_to?(:template) "#{template.path_without_format_and_extension.gsub(%r{/_?}, '.')}#{key}" else "#{controller_name}.#{action_name}#{key}" end else key end end end extend Helper end
Version data entries
10 entries across 10 versions & 1 rubygems