From 8bcc2f900b80648ef34c37f85f926f4ba97472fe Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 8 Jul 2009 18:49:40 +0200 Subject: [PATCH] stop messing with supposedly deprecated interpolation placeholders when no interpolation values have been passed. --- .../i18n_interpolation_deprecation.rb | 2 +- activerecord/test/cases/validations_i18n_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/i18n_interpolation_deprecation.rb b/activerecord/lib/active_record/i18n_interpolation_deprecation.rb index cd634e1..ccb0cac 100644 --- a/activerecord/lib/active_record/i18n_interpolation_deprecation.rb +++ b/activerecord/lib/active_record/i18n_interpolation_deprecation.rb @@ -10,7 +10,7 @@ module I18n protected def interpolate_with_deprecated_syntax(locale, string, values = {}) - return string unless string.is_a?(String) + return string unless string.is_a?(String) && !values.empty? string = string.gsub(/%d|%s/) do |s| instead = DEPRECATED_INTERPOLATORS[s] diff --git a/activerecord/test/cases/validations_i18n_test.rb b/activerecord/test/cases/validations_i18n_test.rb index 6698234..de45edb 100644 --- a/activerecord/test/cases/validations_i18n_test.rb +++ b/activerecord/test/cases/validations_i18n_test.rb @@ -70,6 +70,12 @@ class ActiveRecordValidationsI18nTests < ActiveSupport::TestCase end end + def test_percent_s_interpolation_syntax_not_changed_when_no_values_were_passed + assert_not_deprecated do + I18n.t :does_not_exist, :default => "%d interpolation syntaxes are deprected" + end + end + # ActiveRecord::Errors def test_errors_generate_message_translates_custom_model_attribute_key -- 1.6.0.5