SprintfFormatter.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\I18n\Formatter;
  16. use Aura\Intl\FormatterInterface;
  17. /**
  18. * A formatter that will interpolate variables using sprintf and
  19. * select the correct plural form when required
  20. */
  21. class SprintfFormatter implements FormatterInterface
  22. {
  23. /**
  24. * Returns a string with all passed variables interpolated into the original
  25. * message. Variables are interpolated using the sprintf format.
  26. *
  27. * @param string $locale The locale in which the message is presented.
  28. * @param string|array $message The message to be translated
  29. * @param array $vars The list of values to interpolate in the message
  30. * @return string The formatted message
  31. */
  32. public function format($locale, $message, array $vars)
  33. {
  34. return vsprintf($message, $vars);
  35. }
  36. }