diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-09-04 16:46:12 +0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-09-04 16:46:12 +0200 |
commit | 17628ecfce14abf4f9977300e19f3433488e668f (patch) | |
tree | 15ccfa13fe202b289566aa61d1917dd293236722 /activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb | |
parent | 0d9e238cc938c96708d36bbd2cd4736e9ec93a1e (diff) | |
download | rails-17628ecfce14abf4f9977300e19f3433488e668f.tar.gz rails-17628ecfce14abf4f9977300e19f3433488e668f.tar.bz2 rails-17628ecfce14abf4f9977300e19f3433488e668f.zip |
Deprecate %d and %s in message interpolation, but only in the bundled i18n lib.
Diffstat (limited to 'activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb')
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb index da89b30c54..e2d19cdd45 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb @@ -4,6 +4,7 @@ module I18n module Backend class Simple INTERPOLATION_RESERVED_KEYS = %w(scope default) + DEPRECATED_INTERPOLATORS = { '%d' => '{{count}}', '%s' => '{{value}}' } MATCH = /(\\\\)?\{\{([^\}]+)\}\}/ # Accepts a list of paths to translation files. Loads translations from @@ -107,7 +108,7 @@ module I18n raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key) entry[key] end - + # Interpolates values into a given string. # # interpolate "file {{file}} opened by \\{{user}}", :file => 'test.txt', :user => 'Mr. X' @@ -119,7 +120,11 @@ module I18n def interpolate(locale, string, values = {}) return string unless string.is_a?(String) - string = string.gsub(/%d/, '{{count}}').gsub(/%s/, '{{value}}') + 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 if string.respond_to?(:force_encoding) original_encoding = string.encoding |