Froze rails gems
[depot.git] / vendor / rails / activerecord / lib / active_record / i18n_interpolation_deprecation.rb
1 # Deprecates the use of the former message interpolation syntax in activerecord
2 # as in "must have %d characters". The new syntax uses explicit variable names
3 # as in "{{value}} must have {{count}} characters".
4
5 require 'i18n/backend/simple'
6 module I18n
7 module Backend
8 class Simple
9 DEPRECATED_INTERPOLATORS = { '%d' => '{{count}}', '%s' => '{{value}}' }
10
11 protected
12 def interpolate_with_deprecated_syntax(locale, string, values = {})
13 return string unless string.is_a?(String)
14
15 string = string.gsub(/%d|%s/) do |s|
16 instead = DEPRECATED_INTERPOLATORS[s]
17 ActiveSupport::Deprecation.warn "using #{s} in messages is deprecated; use #{instead} instead."
18 instead
19 end
20
21 interpolate_without_deprecated_syntax(locale, string, values)
22 end
23 alias_method_chain :interpolate, :deprecated_syntax
24 end
25 end
26 end