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
;
15 * IdentityTranslator does not translate anything.
17 * @author Fabien Potencier <fabien@symfony.com>
19 class IdentityTranslator
implements TranslatorInterface
27 * @param MessageSelector|null $selector The message selector for pluralization
29 public function __construct(MessageSelector
$selector = null)
31 $this->selector
= $selector ?
: new MessageSelector();
37 public function setLocale($locale)
39 $this->locale
= $locale;
45 public function getLocale()
47 return $this->locale ?
: \Locale
::getDefault();
53 public function trans($id, array $parameters = array(), $domain = null, $locale = null)
55 return strtr((string) $id, $parameters);
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);