Skip to content
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 6

## main

* Add test to document the current behavior for resolving relative translation keys within partial blocks. When rendering a partial, relative translation keys are resolved relative to the partial’s own path rather than the caller’s path. This test ensures that this behavior remains consistent.

*Oussama Hilal*

* Add Consultport to list of companies using ViewComponent.

*Sebastian Nepote*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= render "shared/partial" do %>
<%= t(".title") %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class RelativeTranslationPartialBlockComponent < ViewComponent::Base
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= render "shared/partial" do %>
<%= t(".title") %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class RelativeTranslationPartialParentComponent < ViewComponent::Base
end
1 change: 1 addition & 0 deletions test/sandbox/app/views/shared/_partial.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= yield %>
4 changes: 4 additions & 0 deletions test/sandbox/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ en:

my_component:
message: "OH NO! (you shouldn't see me)"

shared:
partial:
title: Partial Title
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require "test_helper"

class RelativeTranslationPartialBlockComponentTest < ViewComponent::TestCase
def test_relative_translation_in_partial_block
render_inline(RelativeTranslationPartialBlockComponent.new)

assert_text "Partial Title"
end
end
Loading