Standard yml file with translations of the form:

symfony: is: great: Symfony is great amazing: Symfony is amazing has: bundles: Symfony has bundles user: login: Login 

I get a list of all translations in the controller as follows:

 $translated = $this->container->get('translator') ->getCatalogue($language) ->all(); 

The question is how to get only a certain part of the translation, i.e. as an example only symfony.is translations:

 [ 'symfony.is.great' => 'Symfony is great', 'symfony.is.amazing' => 'Symfony is amazing' ] 
  • Try to load just the yml file through the yml parser. Well, or convert the array with your hands in the desired - danil

1 answer 1

If you want to receive only a part of the translations - move them to a separate file with a different name (called a domain) (in my example it will be frontend):

enter image description here

Now you can get the necessary translations as follows:

 $messages = $this->container->get('translator') ->getCatalogue($language) ->all('frontend');