Sha256: e07bc47c7ebddf844c8e4f516ce867aa3edbdc6f2b40a9b0d91a8546a14d2d3c

Contents?: true

Size: 904 Bytes

Versions: 25

Compression:

Stored size: 904 Bytes

Contents

# encoding: utf-8

module Formtastic
  # @private
  module I18n

    DEFAULT_SCOPE = [:formtastic].freeze
    DEFAULT_VALUES = YAML.load_file(File.expand_path("../../locale/en.yml", __FILE__))["en"]["formtastic"].freeze
    SCOPES = [
        '%{model}.%{nested_model}.%{action}.%{attribute}',
        '%{model}.%{nested_model}.%{attribute}',
        '%{nested_model}.%{action}.%{attribute}',
        '%{nested_model}.%{attribute}',
        '%{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

25 entries across 25 versions & 2 rubygems

Version Path
formtastic-3.1.5 lib/formtastic/i18n.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/lib/formtastic/i18n.rb
formtastic-3.1.4 lib/formtastic/i18n.rb
formtastic-3.1.3 lib/formtastic/i18n.rb
formtastic-3.1.2 lib/formtastic/i18n.rb
formtastic-3.1.1 lib/formtastic/i18n.rb
formtastic-3.1.0 lib/formtastic/i18n.rb
formtastic-3.1.0.rc2 lib/formtastic/i18n.rb
formtastic-3.1.0.rc1 lib/formtastic/i18n.rb
formtastic-3.0.0 lib/formtastic/i18n.rb
formtastic-3.0.0.rc2 lib/formtastic/i18n.rb
formtastic-2.3.1 lib/formtastic/i18n.rb
formtastic-2.3.0 lib/formtastic/i18n.rb
formtastic-3.0.0.rc lib/formtastic/i18n.rb
formtastic-2.3.0.rc4 lib/formtastic/i18n.rb
formtastic-2.3.0.rc3 lib/formtastic/i18n.rb
formtastic-2.3.0.rc2 lib/formtastic/i18n.rb
formtastic-2.3.0.rc lib/formtastic/i18n.rb
formtastic-2.2.1 lib/formtastic/i18n.rb
formtastic-2.2.0 lib/formtastic/i18n.rb