Translate field name displayed within validation error messages? I'm adding validation errors to fields using addErrors($record-&gt;getErrors()) which then read like e.g. "My Field cannot be blank."

But I'm wondering where I can translate the field name, which I think is generated from the ID attribute myField?

Update:

Template:

&lt;input type="hidden" name="action" value="example/saveExample"&gt;

{{ forms.textField({
    label: 'My Field'|t,
    id: 'myField',
    name: 'myField',
    value: null,
    errors: example is defined ? example.errors('myField'),
}) }}


Service function called from actionSaveExample:

public function saveExample(ExampleModel $example)
{
    $exampleRecord = ExampleRecord::model()-&gt;findById($example-&gt;id);
    $exampleRecord-&gt;myField = $example-&gt;myField;

    if ($exampleRecord-&gt;validate())
    {
        // save
    }
    else
    {
        $rule-&gt;addErrors($ruleRecord-&gt;getErrors());

        return false;
    }
}
Craft/Yii sees that string as:

'{attribute} cannot be blank.' =&gt; '{attribute} darf nicht leer sein.',


Where {attribute} is the dynamic part - in this case your field handle.

If I'm understanding your question correctly, there isn't a way to translate that field handle in this context because you're in charge of what it's called to begin with.

I would assume, for example, if you're using the German locale, that you would already have a German context field handle name in place already.