Skip to content

Commit 39b9e59

Browse files
committed
translation filter: add interpolated string
1 parent 0c33693 commit 39b9e59

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/liquid-rails/filters/translate_filter.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ def translate(key, locale = nil, scope = nil)
66

77
@context.registers[:view].translate(key.to_s, locale: locale, scope: scope)
88
end
9+
10+
def t(name, vars={})
11+
@context.registers[:view].translate(name).gsub(/\{\{(.*?)\}\}/) {
12+
"#{vars[$1.strip]}"
13+
}
14+
end
915
end
1016
end
1117
end

0 commit comments

Comments
 (0)