TranslatorHelper.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Bundle\FrameworkBundle\Templating\Helper;
  11. use Symfony\Component\Templating\Helper\Helper;
  12. use Symfony\Component\Translation\TranslatorInterface;
  13. /**
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class TranslatorHelper extends Helper
  17. {
  18. protected $translator;
  19. public function __construct(TranslatorInterface $translator)
  20. {
  21. $this->translator = $translator;
  22. }
  23. /**
  24. * @see TranslatorInterface::trans()
  25. */
  26. public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
  27. {
  28. return $this->translator->trans($id, $parameters, $domain, $locale);
  29. }
  30. /**
  31. * @see TranslatorInterface::transChoice()
  32. */
  33. public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
  34. {
  35. return $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function getName()
  41. {
  42. return 'translator';
  43. }
  44. }