Sha256: 73fd20103a93380839d1f3e8fac76f2f0c149b41c5b040873aeca3390c619a8d

Contents?: true

Size: 828 Bytes

Versions: 9

Compression:

Stored size: 828 Bytes

Contents

module Formtastic
  module I18n
    
    DEFAULT_SCOPE = [:formtastic].freeze
    DEFAULT_VALUES = {
        :required       => 'required',
        :yes            => 'Yes',
        :no             => 'No',
        :create         => 'Create {{model}}',
        :update         => 'Update {{model}}'
      }.freeze
    SCOPES = [
        '{{model}}.{{action}}.{{attribute}}',
        '{{model}}.{{attribute}}',
        '{{attribute}}'
      ]
      
    class << self
      
      def translate(*args)
        key = args.shift.to_sym
        options = args.extract_options!
        options.reverse_merge!(:default => DEFAULT_VALUES[key])
        options[:scope] = [DEFAULT_SCOPE, options[:scope]].flatten.compact
        ::I18n.translate(key, *(args << options))
      end
      alias :t :translate
      
    end
    
  end
end

Version data entries

9 entries across 9 versions & 5 rubygems

Version Path
formtastic-0.9.8 lib/formtastic/i18n.rb
formtastic-rails3-0.9.7 lib/formtastic/i18n.rb
jintastic-1.1.0 vendor/plugins/formtastic/lib/formtastic/i18n.rb
jintastic-1.0.2 vendor/plugins/formtastic/lib/formtastic/i18n.rb
tmayad-formtastic-0.9.7 lib/formtastic/i18n.rb
ShadowBelmolve-formtastic-0.9.7 lib/formtastic/i18n.rb
formtastic-0.9.7 lib/formtastic/i18n.rb
formtastic-0.9.6 lib/formtastic/i18n.rb
formtastic-0.9.5 lib/formtastic/i18n.rb