51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/i18n_routing_rails2.rb', line 51
def define_url_helper(route, name, kind, options)
gl = Thread.current[:globalized]
mkd_define_url_helper(route, name, kind, options)
if gl
selector = url_helper_name(name, kind)
rlang = if i = name.to_s.rindex("_#{gl}")
"#{selector.to_s[0, i]}_glang_#{gl}#{selector.to_s[i + "_#{gl}".size, selector.to_s.size]}"
elsif (gls = Thread.current[:globalized_s]) and i = name.to_s.rindex("_#{gls}")
"#{selector.to_s[0, i]}_glang_#{gls}#{selector.to_s[i + "_#{gls}".size, selector.to_s.size]}"
else
"glang_#{selector}"
end
@module.module_eval <<-end_eval alias_method :gl#{selector}, :#{selector}
def #{selector}(*args)
selector_g = '#{rlang}'.gsub('glang', I18nRouting.locale_escaped(I18n.locale)).to_sym
#logger.debug "Call routes : #{selector} => \#{selector_g} (#{rlang}) "
#puts "Call routes : #{selector} => \#{selector_g} (#{rlang}) Found:\#{respond_to? selector_g and selector_g != :#{selector}}"
if respond_to? selector_g and selector_g != :#{selector}
send(selector_g, *args)
else
gl#{selector}(*args)
end
end
protected :gl#{selector}
end_eval
end
end
|