Another alternative to Gedmo and KnpLabs DoctrineExtension for translate your Doctrine objects. On same approach of the KnpLabs strategy
but with the use of Doctrine Filters.
(Important, no fallback strategy to the default locale will be implemented. You should see the wip-2.4 version of Gedmo Doctrine Extension as alternative)
1. Requirement
Symfony >= v2.3
2. Installation
Use composer
After the successful installation, add in your AppKernel.php file
3. Configuration
There is no minimal configuration. Full list:
[1] Default to doctrine
'doctrine' is the only one manager_registry available currently.
4. Usage
Example for an existing object Product
To internationalize this entity, we need to do some refactors.
First, we move fields, getters and setters concerned by translations into a new object, call the translation object: ObjectTranslation.
Our original object, relieved of some code, is call translatable object.
Our translatable object
Note that 'use \A2lix\I18nDoctrineBundle\Doctrine\ORM\Util\Translatable;' is only possible if you have PHP5.4+, else you need
to copy manually the code of this trait.
Our translation object
Note that, here too, 'use \A2lix\I18nDoctrineBundle\Doctrine\ORM\Util\Translation;' is only possible if you have PHP5.4+, else you need
to copy manually the code of this trait.
5. Advanced
If you use PHP5.4+, you can use some traits provided in Doctrine/O*M/Util
During edition of your forms, you need to use the annotation 'I18nDoctrine'.
For minimize requests number, I advice to specify the join relation about your translations.