From 2d43846d2b2a2e596f30fa58ea1c9ddb2243bb64 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sat, 6 Nov 2010 16:25:34 +0100 Subject: [PATCH] Finally remove deprecated interpolation syntax The interpolation syntax "{{foo}}" has been deprecated since 0.4.0 (https://github.com/svenfuchs/i18n/commit/8894ee521ef5788c415b625a6daf522af4c416e0) and is no being removed. Please use the (Ruby 1.9 native) interplation syntax "%{foo}" instead. --- lib/i18n/backend/base.rb | 11 ----------- lib/i18n/tests/interpolation.rb | 7 ------- 2 files changed, 18 deletions(-) diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index f780371d..628dac19 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -10,7 +10,6 @@ module Base RESERVED_KEYS = [:scope, :default, :separator, :resolve, :object, :fallback] RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/ - DEPRECATED_INTERPOLATION_SYNTAX_PATTERN = /(\\)?\{\{([^\}]+)\}\}/ # Accepts a list of paths to translation files. Loads translations from # plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml @@ -150,16 +149,6 @@ def pluralize(locale, entry, count) def interpolate(locale, string, values = {}) return string unless string.is_a?(::String) && !values.empty? - string = string.gsub(DEPRECATED_INTERPOLATION_SYNTAX_PATTERN) do - escaped, key = $1, $2.to_sym - if escaped - "{{#{key}}}" - else - warn_syntax_deprecation!(locale, string) - "%{#{key}}" - end - end - values.each do |key, value| value = value.call(values) if interpolate_lambda?(value, string, key) value = value.to_s unless value.is_a?(::String) diff --git a/lib/i18n/tests/interpolation.rb b/lib/i18n/tests/interpolation.rb index 64e04c89..06613f27 100644 --- a/lib/i18n/tests/interpolation.rb +++ b/lib/i18n/tests/interpolation.rb @@ -54,13 +54,6 @@ module Interpolation assert_equal 'Hi Yehuda!', interpolate(:interpolate, :name => 'Yehuda') end - test "interpolation: works with the deprecated syntax" do - deprecation = capture(:stderr) do - assert_equal 'Hi David!', interpolate(:default => 'Hi {{name}}!', :name => 'David') - end - assert_match "The {{key}} interpolation syntax in I18n messages is deprecated", deprecation - end - test "interpolation: given the translation is in utf-8 it still works" do assert_equal 'Häi David!', interpolate(:default => 'Häi %{name}!', :name => 'David') end