nelmio / NelmioApiDocBundle

Generates documentation for your REST API from annotations
MIT License
2.21k stars 830 forks source link

Translations using translation_domain are not parsed #1131

Open Sydney-o9 opened 6 years ago

Sydney-o9 commented 6 years ago

This is just a quick note - I have noticed translation_domain passed to configureOptions() in a form type are not parsed.

Here is a simple example:

image

Controller

    /**
     * Create new game.
     *
     * @ApiDoc(
     *  input="AppBundle\Form\Type\Game\GameFormType",
     * )
     */
    public function postAction()

GameFormType

class GameFormType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->add('name', TextType::class, array(
            'label' => 'form.game.name',
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\Game',
            'translation_domain' => 'forms',
        ));
    }

}

Resources/config/translations/forms.en.yml

form:
    game:
        name: Game
Sydney-o9 commented 6 years ago

Happy to contribute if anyone has any direction for me to go into?

GuilhemN commented 5 years ago

Sorry for the late answer, NelmioApiDocBundle 2.x is no longer maintained, we haven't added back form translation support but it would be a great addition if you are still willing to contribute :)