TranslatorFactory.php
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
*
* This file is part of the Aura Project for PHP.
*
* @package Aura.Intl
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*
*/
namespace Aura\Intl;
/**
*
* Factory to create Translator objects.
*
* @package Aura.Intl
*
*/
class TranslatorFactory
{
/**
*
* The class to use for new instances.
*
* @var string
*
*/
protected $class = 'Aura\Intl\Translator';
/**
*
* Returns a new Translator.
*
* @param string $locale The locale code for the translator.
*
* @param array $messages The localized messages for the translator.
*
* @param FormatterInterface $formatter The formatter to use for
* interpolating token values.
*
* @param TranslatorInterface $fallback A fallback translator to use, if
* any.
*
* @return Translator
*
*/
public function newInstance(
$locale,
array $messages,
FormatterInterface $formatter,
TranslatorInterface $fallback = null
) {
$class = $this->class;
return new $class($locale, $messages, $formatter, $fallback);
}
}