diff --git a/lib/liquid/i18n.rb b/lib/liquid/i18n.rb index 44641e4..0404c01 100644 --- a/lib/liquid/i18n.rb +++ b/lib/liquid/i18n.rb @@ -24,10 +24,10 @@ module Liquid private def interpolate(name, vars) - name.gsub(/([^\\]):(\w+)/) { - raise TranslationError, translate("errors.i18n.undefined_interpolation", :key => $1, :name => name) unless vars[$2.to_sym] - "#{$1}#{vars[$2.to_sym]}" - }.gsub("\\:", ":") + name.gsub(/%{(\w+)}/) { + raise TranslationError, translate("errors.i18n.undefined_interpolation", :key => $1, :name => name) unless vars[$1.to_sym] + "#{vars[$1.to_sym]}" + } end def deep_fetch_translation(name) diff --git a/test/fixtures/en_locale.yml b/test/fixtures/en_locale.yml index ee7983f..0b113c6 100644 --- a/test/fixtures/en_locale.yml +++ b/test/fixtures/en_locale.yml @@ -1,9 +1,9 @@ --- simple: "less is more" - whatever: "something :something" + whatever: "something %{something}" errors: i18n: - undefined_interpolation: "undefined key :key" - unknown_translation: "translation ':name' wasn't found" + undefined_interpolation: "undefined key %{key}" + unknown_translation: "translation '%{name}' wasn't found" syntax: oops: "something wasn't right" diff --git a/test/liquid/i18n_test.rb b/test/liquid/i18n_test.rb index 76e7fdf..e6e0d7a 100644 --- a/test/liquid/i18n_test.rb +++ b/test/liquid/i18n_test.rb @@ -34,12 +34,4 @@ class I18nTest < Test::Unit::TestCase def test_sets_default_path_to_en assert_equal I18n::DEFAULT_LOCALE, I18n.new.path end - - def test_escaping_of_symbols - assert_equal "do replaced! not :gsub", @i18n.send(:interpolate, - 'do :replace not \\:gsub', - { - :replace => "replaced!" - }) - end end