1 | <?php |
||
5 | class ResourceTranslator |
||
6 | { |
||
7 | /** @var string */ |
||
8 | private $resourcesDirectory; |
||
9 | |||
10 | /** |
||
11 | * @var \ResourceBundle[] |
||
12 | */ |
||
13 | private $resourceBundles; |
||
14 | |||
15 | /** |
||
16 | * Constructor. |
||
17 | * |
||
18 | * @param $resourcesDirectory |
||
19 | */ |
||
20 | 12 | public function __construct($resourcesDirectory) |
|
25 | |||
26 | /** |
||
27 | * Translate the $resource |
||
28 | * |
||
29 | * @param string $locale |
||
30 | * @param TranslatableResource $resource |
||
31 | * |
||
32 | * @throws \IntlException |
||
33 | * @return string |
||
34 | */ |
||
35 | 12 | public function translate($locale, TranslatableResource $resource) |
|
45 | |||
46 | /** |
||
47 | * Retrieve the pattern from the resource bundle |
||
48 | * |
||
49 | * @param string $locale |
||
50 | * @param string $key |
||
51 | * |
||
52 | * @throws \IntlException |
||
53 | * @return mixed |
||
54 | */ |
||
55 | 12 | private function retrievePattern($locale, $key) |
|
67 | |||
68 | /** |
||
69 | * @param string $locale |
||
70 | * |
||
71 | * @throws \IntlException |
||
72 | * @return \ResourceBundle |
||
73 | */ |
||
74 | 12 | private function getResourceBundle($locale) |
|
88 | } |
||
89 |