Sha256: e408df5de8b8c62efabba9c49a16464c217b2fe43a20b4cb1a6688e16295efd7

Contents?: true

Size: 913 Bytes

Versions: 20

Compression:

Stored size: 913 Bytes

Contents

# Deprecates the use of the former message interpolation syntax in activerecord
# as in "must have %d characters". The new syntax uses explicit variable names
# as in "{{value}} must have {{count}} characters".

require 'i18n/backend/simple'
module I18n
  module Backend
    class Simple
      DEPRECATED_INTERPOLATORS = { '%d' => '{{count}}', '%s' => '{{value}}' }

      protected
        def interpolate_with_deprecated_syntax(locale, string, values = {})
          return string unless string.is_a?(String)

          string = string.gsub(/%d|%s/) do |s|
            instead = DEPRECATED_INTERPOLATORS[s]
            ActiveSupport::Deprecation.warn "using #{s} in messages is deprecated; use #{instead} instead."
            instead
          end

          interpolate_without_deprecated_syntax(locale, string, values)
        end
        alias_method_chain :interpolate, :deprecated_syntax
    end
  end
end

Version data entries

20 entries across 17 versions & 9 rubygems

Version Path
p8-castronaut-0.6.1.1 vendor/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
relevance-castronaut-0.6.0 vendor/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
relevance-castronaut-0.6.1 vendor/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
relevance-castronaut-0.7.4 vendor/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
relevance-castronaut-0.7.5 vendor/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
nbudin-castronaut-0.7.5 vendor/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activerecord/pkg/activerecord-2.3.3/lib/active_record/i18n_interpolation_deprecation.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activerecord/pkg/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb
factorylabs-castronaut-0.7.5 vendor/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
activerecord-2.2.3 lib/active_record/i18n_interpolation_deprecation.rb
webroar-0.2.2 src/admin_panel/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
activerecord-2.3.3 lib/active_record/i18n_interpolation_deprecation.rb
activerecord-2.2.2 lib/active_record/i18n_interpolation_deprecation.rb
activerecord-2.3.2 lib/active_record/i18n_interpolation_deprecation.rb
mack-active_record-0.8.2 lib/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb
mack-active_record-0.8.3.1 lib/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb
mack-active_record-0.8.3 lib/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb
radiant-0.8.0 vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb