I am trying to translate my own constraint messages defined in validation.yml. I have something like this:
Adviser\WebServicesBundle\Entity\Messages:
problem:
- Type:
type: string
- NotBlank: ~
- Length:
min: 2
max: 1000
minMessage: { message: 'author' }
I need to translate the tag minMessage, it works fine if I put a text directly. I have a file named validators.es.yml inside the directory "Resources/translation" where is located the translation message:
author: "Message too short"
I also have proved using a xlf format adding the following content overriding the file validators.es.xlf:
<trans-unit id="81">
<source>author</source>
<target>Message too short</target>
</trans-unit>
I get the same error in both cases, "Array to string conversion" when I submit the form to force the message. This is the piece of code which throws the exception:
$domain = 'messages';
}
$id = (string) $id;
$catalogue = $this->getCatalogue($locale);
$locale = $catalogue->getLocale();
while (!$catalogue->defines($id, $domain)) {
I have followed carefully this documentation with no success http://symfony.com/doc/2.7/book/translation.html#translating-constraint-messages
I am currently working with symfony 2.7 and any other translations work fine throughout the whole project. I just have this problem with own constraint messages, I don't understand why the validation.yml file can't get the defined messages. Is there a way to achieve this?