mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
Change interpolation syntax to %{key}
This commit is contained in:
+4
-4
@@ -24,10 +24,10 @@ module Liquid
|
|||||||
|
|
||||||
private
|
private
|
||||||
def interpolate(name, vars)
|
def interpolate(name, vars)
|
||||||
name.gsub(/([^\\]):(\w+)/) {
|
name.gsub(/%{(\w+)}/) {
|
||||||
raise TranslationError, translate("errors.i18n.undefined_interpolation", :key => $1, :name => name) unless vars[$2.to_sym]
|
raise TranslationError, translate("errors.i18n.undefined_interpolation", :key => $1, :name => name) unless vars[$1.to_sym]
|
||||||
"#{$1}#{vars[$2.to_sym]}"
|
"#{vars[$1.to_sym]}"
|
||||||
}.gsub("\\:", ":")
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def deep_fetch_translation(name)
|
def deep_fetch_translation(name)
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
simple: "less is more"
|
simple: "less is more"
|
||||||
whatever: "something :something"
|
whatever: "something %{something}"
|
||||||
errors:
|
errors:
|
||||||
i18n:
|
i18n:
|
||||||
undefined_interpolation: "undefined key :key"
|
undefined_interpolation: "undefined key %{key}"
|
||||||
unknown_translation: "translation ':name' wasn't found"
|
unknown_translation: "translation '%{name}' wasn't found"
|
||||||
syntax:
|
syntax:
|
||||||
oops: "something wasn't right"
|
oops: "something wasn't right"
|
||||||
|
|||||||
@@ -34,12 +34,4 @@ class I18nTest < Test::Unit::TestCase
|
|||||||
def test_sets_default_path_to_en
|
def test_sets_default_path_to_en
|
||||||
assert_equal I18n::DEFAULT_LOCALE, I18n.new.path
|
assert_equal I18n::DEFAULT_LOCALE, I18n.new.path
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_escaping_of_symbols
|
|
||||||
assert_equal "do replaced! not :gsub", @i18n.send(:interpolate,
|
|
||||||
'do :replace not \\:gsub',
|
|
||||||
{
|
|
||||||
:replace => "replaced!"
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user