IdentityTranslator.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. * @api
  17. */
  18. class IdentityTranslator implements TranslatorInterface
  19. {
  20. private $selector;
  21. /**
  22. * Constructor.
  23. *
  24. * @param MessageSelector $selector The message selector for pluralization
  25. *
  26. * @api
  27. */
  28. public function __construct(MessageSelector $selector)
  29. {
  30. $this->selector = $selector;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. *
  35. * @api
  36. */
  37. public function setLocale($locale)
  38. {
  39. }
  40. /**
  41. * {@inheritdoc}
  42. *
  43. * @api
  44. */
  45. public function getLocale()
  46. {
  47. }
  48. /**
  49. * {@inheritdoc}
  50. *
  51. * @api
  52. */
  53. public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
  54. {
  55. return strtr($id, $parameters);
  56. }
  57. /**
  58. * {@inheritdoc}
  59. *
  60. * @api
  61. */
  62. public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
  63. {
  64. return strtr($this->selector->choose($id, (int) $number, $locale), $parameters);
  65. }
  66. }