8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/i18n_link/helper.rb', line 8
def t_link(translation, options = {})
Rails.logger.warn "DEPRECATION WARNING: t_link and the gem i18n_link are deprecated. Consider updating to the new gem 'it'. Called from #{caller.first}"
options.symbolize_keys!
string = String.new(h(t(translation)))
string.gsub!(/(%\{[^}]+:[^}]*)(%\{[^}]+\})([^}]*\})/) do |tl|
token = $2[2..-2].to_sym
if options.has_key?(token)
"#{$1}#{options[token]}#{$3}"
else
tl
end
end
string.gsub!(/%\{[^}]+\}/) do |tl|
if tl.include?(":")
token, label = tl[2..-2].split(":", 2)
addr = options.delete(token.to_sym)
if addr.nil?
tl
else
link_options = options.delete("#{token}_options".to_sym)
link_to(raw(label), addr, link_options)
end
else
tl
end
end
options.each { |key, value| options[key] = (value.is_a?(String) && !value.html_safe?) ? h(value) : value }
raw(string % options)
end
|