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".
5 require 'i18n/backend/simple'
9 DEPRECATED_INTERPOLATORS
= { '%d' => '{{count}}', '%s' => '{{value}}' }
12 def interpolate_with_deprecated_syntax(locale
, string
, values
= {})
13 return string
unless string
.is_a
?(String
)
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."
21 interpolate_without_deprecated_syntax(locale
, string
, values
)
23 alias_method_chain
:interpolate, :deprecated_syntax