Reputation: 35
I have a Symfony2 project and today I'm asked to make it internationalized.
I have several MySQL entities and the new translated contents that I would like to put in a single table containing:
ID | language | content_key | content_translation
Once the _locale is set, I would like to be able to pass this at Entity level, in order to make the Model layer retrieve the content itselves (making a second call to the translation table if that content is one of the translatable one).
I've tried to use Translatable Extension, but since it is a pre-existing database and project, it is not an easy way to pursue.
How can I inject the request (or pass the _locale only) to my Entities?
Thanks a lot, Andrea
Upvotes: 0
Views: 83
Reputation: 1156
I think you are using Doctrine as ORM with Symfony2?
Then have a look at the Doctrine Extensions. This bundle provides different new behaviors for your entities. It has also a translatable behavior which is really powerfull.
Integrating the doctrine extensions in Symfony2 is not so complicated.
If you can't use the Doctrine Extensions with your Code/Database, i would try the Doctrine Event Listeners to develop the translatable behavior of your own.
Upvotes: 2