diff --git a/lib/i18n.rb b/lib/i18n.rb index d3369704..18c3c761 100644 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -48,7 +48,7 @@ def self.reserve_key(key) end def self.reserved_keys_pattern # :nodoc: - @reserved_keys_pattern ||= /%\{(#{RESERVED_KEYS.join("|")})\}/ + @reserved_keys_pattern ||= /(? :bar, :default => '%%{separator}') + end + + # Note: The two interpolations below do not remove the escape character (%) because + # I18n should not alter the strings when no interpolation parameters are given, + # see the comment at the top of this file. + assert_nothing_raised do + assert_equal '%%{scope}', interpolate(:default => '%%{scope}') + end + + I18n.backend.store_translations(:en, :interpolate => 'Hi %%{scope}!') + assert_nothing_raised do + assert_equal 'Hi %%{scope}!', interpolate(:interpolate) + end + end + test "interpolation: deep interpolation for default string" do assert_equal 'Hi %{name}!', interpolate(:default => 'Hi %{name}!', :deep_interpolation => true) end