Limenius / LiformBundle

Symfony Bundle to render Symfony Forms to JSON Schema
MIT License
138 stars 44 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 7 years ago

grimpows commented 7 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 7 years ago

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