composer package updates
[openemr.git] / vendor / symfony / translation / IdentityTranslator.php
blob46a046365b3241d56bf3eed64e180c097ab21334
1 <?php
3 /*
4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation;
14 /**
15 * IdentityTranslator does not translate anything.
17 * @author Fabien Potencier <fabien@symfony.com>
19 class IdentityTranslator implements TranslatorInterface
21 private $selector;
22 private $locale;
24 /**
25 * Constructor.
27 * @param MessageSelector|null $selector The message selector for pluralization
29 public function __construct(MessageSelector $selector = null)
31 $this->selector = $selector ?: new MessageSelector();
34 /**
35 * {@inheritdoc}
37 public function setLocale($locale)
39 $this->locale = $locale;
42 /**
43 * {@inheritdoc}
45 public function getLocale()
47 return $this->locale ?: \Locale::getDefault();
50 /**
51 * {@inheritdoc}
53 public function trans($id, array $parameters = array(), $domain = null, $locale = null)
55 return strtr((string) $id, $parameters);
58 /**
59 * {@inheritdoc}
61 public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null)
63 return strtr($this->selector->choose((string) $id, (int) $number, $locale ?: $this->getLocale()), $parameters);