Skip to content

Commit d8464f1

Browse files
authored
Merge pull request #117 from cb8/transchoice
Use transChoice for Symfony <4.2
2 parents 8111778 + 126f9f8 commit d8464f1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

DateTimeFormatter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ protected function doGetDiffMessage($count, $invert, $unit)
7979
{
8080
$id = sprintf('diff.%s.%s', $invert ? 'ago' : 'in', $unit);
8181

82-
return $this->translator->trans($id, array('%count%' => $count), 'time');
82+
// check for Symfony >= 4.2
83+
if (class_exists('Symfony\Component\Translation\Formatter\IntlFormatter')) {
84+
return $this->translator->trans($id, array('%count%' => $count), 'time');
85+
} else {
86+
return $this->translator->transChoice($id, $count, array('%count%' => $count), 'time');
87+
}
8388
}
8489

8590
/**

0 commit comments

Comments
 (0)