Reputation: 2184
TL;DR: I would like to programmatically get all Message Translations Domains of an application made with Symfony 3.4.
An example of expected result:
$domains = $this->get('translator')->getDomains();
//$domains = ['home', 'messages', ...]
But i don't find a method returning application domains in translator service. Is there an another service returning all application domains?
Thanks!
Upvotes: 2
Views: 2313
Reputation: 2184
Ok i found the solution:
$this->getContainer()->get('translator')->getCatalogue()->getDomains();
This solution works for bundles if you store their translations as Symfony 3.4 recommend it : in bundles/Resources/translations/
folder.
Otherwise you should precise the path in in config.yml:
framework:
translator:
...
paths:
- '%kernel.project_dir%/xxx/translations'
Upvotes: 3