views:

317

answers:

1

Hi!

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

+1  A: 

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.

JRL
no reaction. I've tried to use _labels.model.attributes_, _helpers.model.attributes_ etc - no results
fl00r
I've figured it out, that Rails 3 don't use human_attribute_name by default in errors listing.
fl00r