I have a nested attribute on which I perform presence validation. I am trying without success to provide translations for the attribute name that is returned in the full error message text.
The model is called Identity
and contains an attribute called identity
The model is nested within another with a has_many
relationship.
A typical error message is currently returned like this
Identities identity can't be blank
I want to translate the attribute (by default Identities identity
) into something else.
I have
en:
activerecord:
models:
identity:
identity: "whatever"
If I do this, I get an error
I18n::InvalidPluralizationData (translation data {:identity=>"whatever"} can not be used with :count => 1):
I have tried to add pluralisation data to this by altering the above to
en:
activerecord:
models:
identity:
identity:
one: "one"
other: "other"
This changes the error to
I18n::InvalidPluralizationData (translation data {:identity=>{:one=>"one", :other=>"other"}} can not be used with :count => 1):
I have also tried many
instead of other
without difference.
I have spent a few hours trying to make this work, having read other questions on Stack Overflow and elsewhere, without success. What is the correct way to write translations for attribute names ?