Reputation: 1084
I've looked at lots of stackoverflow questions to find a solution, with different descriptions of how to correctly write the yml file to ensure a proper translation of error messages for nested attributes.
For me attributes are not the problem, the model name is the problem.
A company has_many signatories. I wrote a message for this:
validates :signatories, length: {minimum: 1, message: _("Signatories should have at least one authorized signatory")}
However, due to the way the full_message method builds it, my message looks like: "Signatory Signatories should have at least one authorized signatory"
I've tried multiple variations in my en.yml as per the below. Any ideas regarding the structure to ensure the model name is translated?
en:
activerecord:
models:
user: User
company: Company
company/signatory: #This seems good for attributes, but not for the model name
one: Signatory
other: Signatories
party: Party
signatory:
one: Signatory #This is correct for the model name, but doesn't help with error messages
other: Signatories ```
Upvotes: 1
Views: 1167
Reputation: 1134
How about the following?
en:
activerecord:
models:
company: Company
signatory:
one: Signatory
other: Signatories
attributes:
company:
signatory:
one: Signatory
other: Signatories
From the documentation
Upvotes: 1