These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace OcLegacy\Translation; |
||
4 | |||
5 | use Symfony\Component\Translation\Formatter\MessageFormatter; |
||
6 | use Symfony\Component\Translation\Loader\YamlFileLoader; |
||
7 | use Symfony\Component\Translation\Translator; |
||
8 | use Symfony\Contracts\Translation\TranslatorInterface; |
||
9 | |||
10 | class TranslationService implements TranslatorInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var Translator |
||
14 | */ |
||
15 | private $translator; |
||
16 | |||
17 | public function __construct() |
||
18 | { |
||
19 | $translator = new Translator('de', new MessageFormatter()); |
||
20 | $translator->setFallbackLocales(['en']); |
||
21 | |||
22 | $yamlLoader = new YamlFileLoader(); |
||
23 | $translator->addLoader('yml', $yamlLoader); |
||
24 | |||
25 | foreach (['de', 'fr', 'nl', 'es', 'pl', 'it', 'ru'] as $languageKey) { |
||
26 | $translator->addResource('yml', __DIR__ . '/../../../app/Resources/translations/constants.' . $languageKey . '.yml', $languageKey); |
||
27 | $translator->addResource('yml', __DIR__ . '/../../../app/Resources/translations/messages.' . $languageKey . '.yml', $languageKey); |
||
28 | $translator->addResource('yml', __DIR__ . '/../../../app/Resources/translations/validators.' . $languageKey . '.yml', $languageKey); |
||
29 | } |
||
30 | |||
31 | $this->translator = $translator; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public function trans($id, array $parameters = [], $domain = null, $locale = null) |
||
38 | { |
||
39 | return $this->translator->trans($id, $parameters, $domain, $locale); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) |
||
46 | { |
||
47 | return $this->translator->transChoice($id, $number, $parameters, $domain, $locale); |
||
0 ignored issues
–
show
|
|||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function setLocale($locale) |
||
54 | { |
||
55 | return $this->translator->setLocale($locale); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function getLocale() |
||
62 | { |
||
63 | return $this->translator->getLocale(); |
||
64 | } |
||
65 | } |
||
66 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.