Skip to content

Commit

Permalink
Symfony 5.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
umpirsky committed Nov 11, 2022
1 parent f45af09 commit ca9a16b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface as TranslatorContract;

/**
* Normalizes invalid Form instances.
Expand Down Expand Up @@ -96,7 +97,11 @@ private function convertFormToArray(FormInterface $data)
private function getErrorMessage(FormError $error)
{
if (null !== $error->getMessagePluralization()) {
return $this->translator->transChoice($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), 'validators');
if ($this->translator instanceof TranslatorContract) {
return $this->translator->trans($error->getMessageTemplate(), ['%count%' => $error->getMessagePluralization()] + $error->getMessageParameters(), 'validators');
} else {
return $this->translator->transChoice($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), 'validators');
}
}

return $this->translator->trans($error->getMessageTemplate(), $error->getMessageParameters(), 'validators');
Expand Down

0 comments on commit ca9a16b

Please sign in to comment.