Symfony 2 JMSTranslationsBundle表格可以选择如何创建翻译术语?

I have a simple form with a choice type which is an simple entity:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('name', 'entity', [
            'class' => 'AppBundle\Entity\Type',
                'property' => 'name',
                'expanded' => true
        ]
    );
}

The entity type is a database table with just an idType AI column and a name column.

The database content is also pretty simple:

idType      name
"1"         "term.inquiry"
"2"         "term.tender"

And the result in a twig file looks pretty simple too:

{{ form_start(form) }}
    {{ form_widget(form.name) }}
{{ form_end(form) }}

I'm really stucked in how to implement the translation method to translate the term.inquiry and term.tender

I've looked up the documentation here, but I don't know how to implement (the correct way) the getTranslationMessages method via the TranslationContainerInterface. I've also tried the answer here but didn't know how to match the return array with the choices in my buildForm method.

Any suggestions or hints for a best practice implementation? Many thanks in advance

you're maybe searching for the option choice_translation_domain introduced in symfony 2.7 as well as choice_label deprecating property.

see http://symfony.com/doc/current/reference/forms/types/choice.html#choice-translation-domain

if your translations are in src/AppBundle/Resources/translations/entity.en.yml, containing :

term:
    inquiry: 'A name'
    tender: 'Another name'

You can write something like :

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('name', 'entity', array(
            'class' => 'AppBundle\Entity\Type',
            //'property' => 'name', is deprecated use 'choice_label' instead
            'expanded' => true,
            'choice_label' => 'name',
            'choice_translation_domain' => 'entity',
        ));
}