Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/translation/Formatter/MessageFormatter.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\Translation\Formatter; | |
13 | |
14 use Symfony\Component\Translation\MessageSelector; | |
15 | |
16 /** | |
17 * @author Abdellatif Ait boudad <a.aitboudad@gmail.com> | |
18 */ | |
19 class MessageFormatter implements MessageFormatterInterface, ChoiceMessageFormatterInterface | |
20 { | |
21 private $selector; | |
22 | |
23 /** | |
24 * @param MessageSelector|null $selector The message selector for pluralization | |
25 */ | |
26 public function __construct(MessageSelector $selector = null) | |
27 { | |
28 $this->selector = $selector ?: new MessageSelector(); | |
29 } | |
30 | |
31 /** | |
32 * {@inheritdoc} | |
33 */ | |
34 public function format($message, $locale, array $parameters = array()) | |
35 { | |
36 return strtr($message, $parameters); | |
37 } | |
38 | |
39 /** | |
40 * {@inheritdoc} | |
41 */ | |
42 public function choiceFormat($message, $number, $locale, array $parameters = array()) | |
43 { | |
44 $parameters = array_merge(array('%count%' => $number), $parameters); | |
45 | |
46 return $this->format($this->selector->choose($message, (int) $number, $locale), $locale, $parameters); | |
47 } | |
48 } |