IdentityTranslator.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation;
  11. /**
  12. * IdentityTranslator does not translate anything.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class IdentityTranslator implements TranslatorInterface
  17. {
  18. private $selector;
  19. /**
  20. * Constructor.
  21. *
  22. * @param MessageSelector $selector The message selector for pluralization
  23. */
  24. public function __construct(MessageSelector $selector)
  25. {
  26. $this->selector = $selector;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function setLocale($locale)
  32. {
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function getLocale()
  38. {
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
  44. {
  45. return strtr($id, $parameters);
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
  51. {
  52. return strtr($this->selector->choose($id, (int) $number, $locale), $parameters);
  53. }
  54. }