I have a multiple apps project looking like this
/apps/app1
/apps/app2
/apps/app3
/apps/config
/src
/vendor
/web/app1
/web/app2
/web/app3
Each app has its kernel, console, cache, ... But how do I share common translations ?
I read there https://stackoverflow.com/a/11630933/689429 that on a one-app structure, you can use app/Resources/translations
. How about a multiples-apps structure ?
I wish I could make /apps/Resources/translations
that would be autoloaded (or loaded manually) in all my apps but is it even possible ?
Haven't tried it yet, but perhaps the following is possible:
Write and register an EventListener on kernel.request
in one of your apps and inject the translator service in it, so you are able to modify it. Maybe it needs to be executed before the LocaleListener
which means it has to have a priority
higher than 16 to be executed before.
Then in the onKernelRequest()
method of your event listener, you could then call the Symfony\Component\Translation\Translator::addResource()
method to add translation files on the fly.
See: http://api.symfony.com/2.3/Symfony/Component/Translation/Translator.html#method_addResource
The parameter $resource
contains the path to your global translation files.
(What you are trying to do really is an edge case, but there has to be some method to do it without symlinking everything.)
Hope this thought helps. I'll try it out as soon as possible and post my results and how I've done it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With