I've also been running into this issue. But because I use the i18n-tasks gem to keep my localisation file in check I've chosen to write out the absolute path for a translation when using them within render blocks.
Basically what happens is as soon as you put a relative translation in a render block the path gets changed. In your example it would be: "application.section.title".
One way to approach this could be to pass the i18n scope of the view to the partial and use that when translating a key.
Something like:
<%= render "section", i18n_scope: @virtual_path.gsub(%r{/_?}, ".") do %>
<h2><%= t('title', scope: i18n_scope) %></h2>
<% end %>
Note the removed dot before "title" indicating this is not a relative lookup.
I think landing on "Use absolute paths at all times with I18n" is great advice, especially since the lookup inference pattern is pretty unique to Rails.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I've also been running into this issue. But because I use the i18n-tasks gem to keep my localisation file in check I've chosen to write out the absolute path for a translation when using them within render blocks.
Basically what happens is as soon as you put a relative translation in a render block the path gets changed. In your example it would be: "application.section.title".
One way to approach this could be to pass the i18n scope of the view to the partial and use that when translating a key.
Something like:
Note the removed dot before "title" indicating this is not a relative lookup.
I think landing on "Use absolute paths at all times with I18n" is great advice, especially since the lookup inference pattern is pretty unique to Rails.