-
Notifications
You must be signed in to change notification settings - Fork 484
Relative translation keys inside blocks resolve to partials scope instead of callers scope #2432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hi @AckermannTM thanks for creating the bug reproduction! If I try running your test and inserting a
<%= render "shared/partial" do %>
<%= t(".title") %>
<% binding.irb %>
<% end %>
vs <%= render "shared/partial" do %>
<%= t(".title") %>
<% end %>
<% binding.irb %>
|
|
Hey @myabc, thanks for looking into this! That explanation makes sense. Inside a render block it is ActionView handling translations, and outside it falls back to the ViewComponent implementation. So this is not a ViewComponent issue but the expected ActionView behavior when rendering a partial inside a component. I thought it might be a ViewComponent issue since it worked in version Looks like it’s time to replace all partials with components in my project 😄 |
Translations inside a render block are handled by ActionView and so the relative paths no longer work. This appears to be expected behaviour that was not working correctly in previous versions of ViewComponent. See ViewComponent/view_component#2432 (comment)
|
Thanks @AckermannTM for taking the time to create this PR and @myabc for chiming in! Since it's not a ViewComponent issue, do you think it would be useful to modify the failing tests in order to document the expected behavior? |
|
Hey @Spone , thanks for the suggestion! I'm sorry for replying this late. I'm going to adjust the test to document this behavior. |
What are you trying to accomplish?
Relative translations in a block use the path of the block, instead of the caller. See #2413
What approach did you choose and why?
Created an issue to describe the problem and was asked to create a failing test PR.
It took me some time to put the PR together 😅
Anything you want to highlight for special attention from reviewers?
I just hope I did everything correctly