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:
17: use Aura\Intl\FormatterInterface;
18:
19: /**
20: * A formatter that will interpolate variables using sprintf and
21: * select the correct plural form when required
22: */
23: class SprintfFormatter implements FormatterInterface
24: {
25: /**
26: * Returns a string with all passed variables interpolated into the original
27: * message. Variables are interpolated using the sprintf format.
28: *
29: * @param string $locale The locale in which the message is presented.
30: * @param string|array $message The message to be translated
31: * @param array $vars The list of values to interpolate in the message
32: * @return string The formatted message
33: */
34: public function format($locale, $message, array $vars)
35: {
36: unset($vars['_singular']);
37:
38: return vsprintf($message, $vars);
39: }
40: }
41: