Reading up on ActionView::Helpers::FormHelper, I see that it states:
The text of label will default to the attribute name unless a translation is found in the current I18n locale (through helpers.label..) or you specify it explicitly.
So you should be able to create a translation for a title label on a post resource like this:
app/views/posts/new.html.erb
<% form_for @post do |f| %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.submit %>
<% end %>
config/locales/en.yml
en:
helpers:
label:
post:
title: 'Customized title'
or
config/locales/en.yml
en:
activerecord:
attributes:
post:
title: 'Customized title'
Is there any way of automatically extracting all form labels and adding the correct keys for them to the i18n locale files? Similarly to what the i18n-tasks
gem does for I18n.t
defined keys.