Skip to content

Commit

Permalink
Finally remove deprecated interpolation syntax
Browse files Browse the repository at this point in the history
The interpolation syntax "{{foo}}" has been deprecated since 0.4.0 (ruby-i18n@8894ee5) and is no being removed. Please use the (Ruby 1.9 native) interplation syntax "%{foo}" instead.
  • Loading branch information
Sven Fuchs committed Nov 6, 2010
1 parent 23c9fef commit 2d43846
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
11 changes: 0 additions & 11 deletions lib/i18n/backend/base.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions lib/i18n/tests/interpolation.rb
Expand Up @@ -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
Expand Down

0 comments on commit 2d43846

Please sign in to comment.