Skip to content

Commit

Permalink
Merge pull request #67 from umpirsky/issue-66
Browse files Browse the repository at this point in the history
Symfony 5.0 compatibility
  • Loading branch information
nacmartin authored Mar 17, 2023
2 parents 2949bef + ca9a16b commit 4b578cb
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 4b578cb

Please sign in to comment.