title: Translating validation error messages in a custom FormType
body: <p>I have the current situation</p>
  
  <pre><code>&lt;?php
  
  namespace MyBundle\Form\Type;
  
  use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\Validator\Constraints as Assert;
  
  class MyFormType extends AbstractType implements ContainerAwareInterface
  {
      use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $translator = $this-&gt;container-&gt;get('translator');
  
          $builder-&gt;add('my-field', 'text', [
              'constraints' =&gt; [
                  new Assert\NotBlank([
                      'message' =&gt; $translator-&gt;trans('%field% should not be blank.', ['%field%' =&gt; $translator-&gt;trans('MyFieldName')]),
                  ]),
              ],
          ]);
      }
  
      public function getName()
      {
          return 'my_form';
      }
  }
  </code></pre>
  
  <p>This example already works, I am trying to refactor it so I don't have to include the container (or the translator) in it.</p>
  
  <p>The challenge lies in keeping</p>
  
  <ul>
  <li>'%field% should not be blank.' and</li>
  <li>'MyFieldName'</li>
  </ul>
  
  <p>as the only two translatable strings, 'cause it's likely that MyFieldName is going to be translated already (like for labels) leaving '%field% should not be blank.' as a generic message valid for any field in the site.</p>