Download symfony2 translations from user directory

as we all know, Symfony2 is looking for translations in these directories:

YourBundle\Resources\translations\ - here lot of .yml files app\Resources\translations\ - here lot of .yml files 

But what if I want to put my translations in

MyBundle\Resources\translations\2015_04_23\ - and lot of .yml files will lay here

I read the documents, but did not see the solution, maybe? Maybe I missed part of the document? Can someone help me? Thanks!

+6
source share
1 answer

Indeed, it is documented here: http://symfony.com/doc/current/components/translation/custom_formats.html#components-translation-custom-loader

You do the same as in the document, but when you use your translation loader, you add the translation by choosing your directory:

 $translator->addResource('my_format', __DIR__.'/translations/messages.txt', 'fr_FR'); 

(you just need to replace __DIR__ with your reasonably selected directory, try to be careful if, for example, you use dynamics files: you should use, for example, a service to make sure your code is easy to maintain)

+1
source

Source: https://habr.com/ru/post/985773/


All Articles