administrate
administrate copied to clipboard
I18n translations for nested resources on custom designs not working
Thank you for this wonderful gem.
-
What were you trying to do? I customized the designs to use TailwindCSS. Everything is working, but the translation for nested records does not work. The same models have their translations on their own index and show pages.
-
What did you end up with (logs, or, even better, example apps are great!)?
We are looking at a custom show page.
The nested
Address
record has no localized labels. The same view for the same record on its own SHOW page:
And the Address
es INDEX page:
The code to render the attributes on the SHOW page:
I believe it is almost the same as the original one.
<% page.attributes.each do |attribute| %>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm font-medium text-gray-500" id="<%= attribute.name %>">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: page.resource.class.human_attribute_name(attribute.name),
) %>
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<%= render_field attribute, page: page %>
</dd>
</div>
<% end %>
Do I need to edit some other files to achieve this?
- What versions are you running?
- Rails 7.0.2.4
- administrate 0.17.0
Thank you for raising this issue. I had a look and I can see it's indeed a bug. Would you be able to try out this branch and see if it works for you? https://github.com/thoughtbot/administrate/compare/main...pablobm:has-one-translations
Thank you for raising this issue. I had a look and I can see it's indeed a bug. Would you be able to try out this branch and see if it works for you? main...pablobm:has-one-translations
I can report back that your branch works for me. I can now define the translations for the models where they belong. 🎉
Perfect, thank you! I'll create a PR.