Reputation: 83680
I've got some form for user registration and want to localize it via locales yml files. Especially errors from validations.
For example, locale file:
tr:
activerecord:
errors:
models:
user:
attributes:
name:
blank: "can't be blank"
it will return: name can't be blank
in errors area:
<% @user.errors.each do |error| -%>
<p><%= error %></p>
<% end -%>
Next step I want to create is to rename name attribute (and others) like that (this is what don't work):
tr:
attributes:
user:
name: "Real name"
to get this error after validation: Real name can't be blank
So where I should locale attribute names to translate them in error messages
Upvotes: 1
Views: 989
Reputation: 77995
Try this:
tr:
activerecord:
attributes:
modelname:
attributename: "translation"
Substituting modelname with the name of your model, and attributename with the name of the attribute you want to provide a translation for, here name.
Upvotes: 1