instiki/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
Jacques Distler 4bdf703ab2 Instiki 0.17.2: Security Release
This release upgrades Instiki to Rails 2.3.4, which
patches two security holes in Rails. See

  http://weblog.rubyonrails.org/2009/9/4/ruby-on-rails-2-3-4

There are also some new features, and the usual boatload
of bugfixes. See the CHANGELOG for details.
2009-09-05 02:01:46 -05:00

26 lines
931 B
Ruby

# 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) && !values.empty?
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