TranslatorInterface.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. use Symfony\Component\Translation\Exception\InvalidArgumentException;
  12. /**
  13. * TranslatorInterface.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. */
  17. interface TranslatorInterface
  18. {
  19. /**
  20. * Translates the given message.
  21. *
  22. * @param string $id The message id (may also be an object that can be cast to string)
  23. * @param array $parameters An array of parameters for the message
  24. * @param string|null $domain The domain for the message or null to use the default
  25. * @param string|null $locale The locale or null to use the default
  26. *
  27. * @return string The translated string
  28. *
  29. * @throws InvalidArgumentException If the locale contains invalid characters
  30. */
  31. public function trans($id, array $parameters = array(), $domain = null, $locale = null);
  32. /**
  33. * Translates the given choice message by choosing a translation according to a number.
  34. *
  35. * @param string $id The message id (may also be an object that can be cast to string)
  36. * @param int $number The number to use to find the indice of the message
  37. * @param array $parameters An array of parameters for the message
  38. * @param string|null $domain The domain for the message or null to use the default
  39. * @param string|null $locale The locale or null to use the default
  40. *
  41. * @return string The translated string
  42. *
  43. * @throws InvalidArgumentException If the locale contains invalid characters
  44. */
  45. public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null);
  46. /**
  47. * Sets the current locale.
  48. *
  49. * @param string $locale The locale
  50. *
  51. * @throws InvalidArgumentException If the locale contains invalid characters
  52. */
  53. public function setLocale($locale);
  54. /**
  55. * Returns the current locale.
  56. *
  57. * @return string The locale
  58. */
  59. public function getLocale();
  60. }