protected static function injectTranslatorValue(TranslatorInterface $translator, TemplateInterface $template, $field): void
    {
        $setter = 'set'.ucfirst($field);
        $getter = 'get'.ucfirst($field);
        $refTpl = new \ReflectionClass($template);

        if ($refTpl->hasMethod($getter) && $refTpl->hasMethod($setter)) {
            $val = $template->{$getter}();

            if (null !== $val) {
                $template->{$setter}($translator->trans($val, [], $template->getTranslationDomain()));
            }
        }
    }
protected static function injectTranslatorValue(TranslatorInterface $translator, TemplateInterface $template, $field): void
    {
        $setter = 'set'.ucfirst($field);
        $getter = 'get'.ucfirst($field);
        $refTpl = new \ReflectionClass($template);

        if ($refTpl->hasMethod($getter) && $refTpl->hasMethod($setter)) {
            $val = $template->{$getter}();

            if (null !== $val) {
                $template->{$setter}($translator->trans($val, [], $template->getTranslationDomain()));
            }
        }
    }
protected static function injectTranslatorValue ( TranslatorInterface $ translator , TemplateInterface $ template , $ field ) : void { $ setter = 'set' . ucfirst ( $ field ) ; $ getter = 'get' . ucfirst ( $ field ) ; $ refTpl = new \ ReflectionClass ( $ template ) ; if ( $ refTpl -> hasMethod ( $ getter ) && $ refTpl -> hasMethod ( $ setter ) ) { $ val = $ template -> { $ getter } ( ) ; if ( null !== $ val ) { $ template -> { $ setter } ( $ translator -> trans ( $ val , [ ] , $ template -> getTranslationDomain ( ) ) ) ; } } }
Inject the translation value of translator in template.

@param TranslatorInterface $translator The translator
@param TemplateInterface   $template   The template instance
@param string              $field      The field

@throws
Inject the translation value of translator in template .