Limenius / LiformBundle

Symfony Bundle to render Symfony Forms to JSON Schema
MIT License
137 stars 43 forks source link

Abstract transformer need to use translation domain for correct label translation and should be used for placeholder too #4

Closed grimpows closed 6 years ago

grimpows commented 6 years ago

Thanks for this great usefull bundle, i just got a problem, you call translator "As It" without check for any translation domain who can be specified in symfony form builder, and look like you dont use translator at all for placeholder, as i'm going to have a base project who have to be able to maintain multi-language functionality i think you just need a little change to make translator work like a charm without put all in a messages.{lang}.yml



namespace Limenius\Liform\Transformer;

abstract class AbstractTransformer {

///...

protected function addLabel($form, $schema)
    {
        if ($label = $form->getConfig()->getOption('label')) {
            $schema['title'] = $this->translator->trans($label); // <----- should be ' .... '->trans($label, [], $TranslationDomainSpecifiedFromSymfonyFormBuildler )
        } else {
            $schema['title'] = $this->translator->trans($form->getName());
        }

        return $schema;
    }

//....

}

Edit : this is related to https://github.com/Limenius/Liform i'll make a PR to solve this issue
nacmartin commented 6 years ago

Fixed by https://github.com/Limenius/Liform/pull/15