Is there a way to translate the labels in a scaffold?
Using <%= f.label :lastname %> instead of having to change that to <label><%= t(:firstname) %></label>
Is there a way to translate the labels in a scaffold?
Using <%= f.label :lastname %> instead of having to change that to <label><%= t(:firstname) %></label>
Cant test it straight away, but
f.label(t(:whatever))
should do the trick
Norbert Melzer wrote in post #1033193:
Cant test it straight away, but
f.label(t(:whatever))
should do the trick
Thanks.
Would be great if the possibility to localize could be built-in directly in scaffold.
After some more research, it is!
Given a Model "User" with the attribute "name"
some view with a form in it: form_for @user do |f| f.label :name end
this will create a label for the input field with id :name AND label this according to the result that "User.human_attribute_name(:name)" would give.
just see label as an alias for
f.label :name, @user.class.human_attribute_name(:name)
Put in your locale then this structure:
en: activerecord: attributes: user: name: "The word your mother says when refering to you"
I stumbled upon this during my research. I wanted to create scaffold generators that do I18n. Here is the URL to the guides:
<Rails Internationalization (I18n) API — Ruby on Rails Guides;
HTH Norbert