mirror of https://github.com/rails/rails
scope_key_by_partial fix for Ruby 1.9 when there's virtual_path [#4202 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
parent
7a5da21481
commit
0c1ac36ccb
|
@ -29,9 +29,10 @@ module ActionView
|
|||
private
|
||||
|
||||
def scope_key_by_partial(key)
|
||||
if (key.respond_to?(:join) ? key.join : key.to_s).first == "."
|
||||
strkey = key.respond_to?(:join) ? key.join : key.to_s
|
||||
if strkey.first == "."
|
||||
if @_virtual_path
|
||||
@_virtual_path.gsub(%r{/_?}, ".") + key.to_s
|
||||
@_virtual_path.gsub(%r{/_?}, ".") + strkey
|
||||
else
|
||||
raise "Cannot use t(#{key.inspect}) shortcut because path is not available"
|
||||
end
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<%= t(['.foo', '.bar']) %>
|
|
@ -41,4 +41,10 @@ class TranslationHelperTest < ActiveSupport::TestCase
|
|||
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
|
||||
assert_equal "helper", @view.render(:file => "test/translation")
|
||||
end
|
||||
|
||||
def test_scoping_by_partial_of_an_array
|
||||
I18n.expects(:translate).with("test.scoped_array_translation.foo.bar", :raise => true).returns(["foo", "bar"])
|
||||
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
|
||||
assert_equal "foobar", @view.render(:file => "test/scoped_array_translation")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue